mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6164 from goerz/inheritance_diagram
Fix docs of inheritance-diagram "parts" option
This commit is contained in:
commit
e6cc18cc59
@ -37,6 +37,7 @@ matrix:
|
|||||||
services: xvfb
|
services: xvfb
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- "sudo apt-get install graphviz"
|
||||||
- if [ $IS_PYTHON = true ]; then pip install -U tox codecov; fi
|
- if [ $IS_PYTHON = true ]; then pip install -U tox codecov; fi
|
||||||
- if [ $IS_PYTHON = false ]; then npm install; fi
|
- if [ $IS_PYTHON = false ]; then npm install; fi
|
||||||
|
|
||||||
|
1
CHANGES
1
CHANGES
@ -89,6 +89,7 @@ Bugs fixed
|
|||||||
* AssertionError is raised when custom ``citation_reference`` node having
|
* AssertionError is raised when custom ``citation_reference`` node having
|
||||||
classes attribute refers missing citation (refs: #6147)
|
classes attribute refers missing citation (refs: #6147)
|
||||||
* #2155: Support ``code`` directive
|
* #2155: Support ``code`` directive
|
||||||
|
* #4872: ext.inheritance_diagram: correctly describe behavior of ``parts`` option in docs, allow negative values.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -7,7 +7,7 @@ import sphinx
|
|||||||
|
|
||||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
|
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
|
||||||
'sphinx.ext.autosummary', 'sphinx.ext.extlinks',
|
'sphinx.ext.autosummary', 'sphinx.ext.extlinks',
|
||||||
'sphinx.ext.viewcode']
|
'sphinx.ext.viewcode', 'sphinx.ext.inheritance_diagram']
|
||||||
|
|
||||||
master_doc = 'contents'
|
master_doc = 'contents'
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
@ -25,12 +25,18 @@ It adds this directive:
|
|||||||
graph.
|
graph.
|
||||||
|
|
||||||
This directive supports an option called ``parts`` that, if given, must be an
|
This directive supports an option called ``parts`` that, if given, must be an
|
||||||
integer, advising the directive to remove that many parts of module names
|
integer, advising the directive to keep that many dot-separated parts
|
||||||
from the displayed names. (For example, if all your class names start with
|
in the displayed names (from right to left). For example, ``parts=1`` will
|
||||||
``lib.``, you can give ``:parts: 1`` to remove that prefix from the displayed
|
only display class names, without the names of the modules that contain
|
||||||
node names.)
|
them.
|
||||||
|
|
||||||
It also supports a ``private-bases`` flag option; if given, private base
|
.. versionchanged:: 2.0
|
||||||
|
The value of for ``parts`` can also be negative, indicating how many
|
||||||
|
parts to drop from the left. For example, if all your class names start
|
||||||
|
with ``lib.``, you can give ``:parts: -1`` to remove that prefix from the
|
||||||
|
displayed node names.
|
||||||
|
|
||||||
|
The directive also supports a ``private-bases`` flag option; if given, private base
|
||||||
classes (those whose name starts with ``_``) will be included.
|
classes (those whose name starts with ``_``) will be included.
|
||||||
|
|
||||||
You can use ``caption`` option to give a caption to the diagram.
|
You can use ``caption`` option to give a caption to the diagram.
|
||||||
@ -92,6 +98,41 @@ It adds this directive:
|
|||||||
Added ``top-classes`` option to limit the scope of inheritance graphs.
|
Added ``top-classes`` option to limit the scope of inheritance graphs.
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
The following are different inheritance diagrams for the internal
|
||||||
|
``InheritanceDiagram`` class that implements the directive.
|
||||||
|
|
||||||
|
With full names::
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
|
||||||
|
|
||||||
|
Showing class names only::
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
:parts: 1
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
:parts: 1
|
||||||
|
|
||||||
|
Stopping the diagram at :class:`sphinx.util.docutils.SphinxDirective` (the
|
||||||
|
highest superclass still part of Sphinx), and dropping the common left-most
|
||||||
|
part (``sphinx``) from all names::
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
:top-classes: sphinx.util.docutils.SphinxDirective
|
||||||
|
:parts: -1
|
||||||
|
|
||||||
|
.. inheritance-diagram:: sphinx.ext.inheritance_diagram.InheritanceDiagram
|
||||||
|
:top-classes: sphinx.util.docutils.SphinxDirective
|
||||||
|
:parts: -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
@ -167,11 +167,17 @@ class InheritanceGraph:
|
|||||||
"""Return name and bases for all classes that are ancestors of
|
"""Return name and bases for all classes that are ancestors of
|
||||||
*classes*.
|
*classes*.
|
||||||
|
|
||||||
*parts* gives the number of dotted name parts that is removed from the
|
*parts* gives the number of dotted name parts to include in the
|
||||||
displayed node names.
|
displayed node names, from right to left. If given as a negative, the
|
||||||
|
number of parts to drop from the left. A value of 0 displays the full
|
||||||
|
dotted name. E.g. ``sphinx.ext.inheritance_diagram.InheritanceGraph``
|
||||||
|
with ``parts=2`` or ``parts=-2`` gets displayed as
|
||||||
|
``inheritance_diagram.InheritanceGraph``, and as
|
||||||
|
``ext.inheritance_diagram.InheritanceGraph`` with ``parts=3`` or
|
||||||
|
``parts=-1``.
|
||||||
|
|
||||||
*top_classes* gives the name(s) of the top most ancestor class to traverse
|
*top_classes* gives the name(s) of the top most ancestor class to
|
||||||
to. Multiple names can be specified separated by comma.
|
traverse to. Multiple names can be specified separated by comma.
|
||||||
"""
|
"""
|
||||||
all_classes = {}
|
all_classes = {}
|
||||||
py_builtins = vars(builtins).values()
|
py_builtins = vars(builtins).values()
|
||||||
@ -332,7 +338,7 @@ class InheritanceDiagram(SphinxDirective):
|
|||||||
optional_arguments = 0
|
optional_arguments = 0
|
||||||
final_argument_whitespace = True
|
final_argument_whitespace = True
|
||||||
option_spec = {
|
option_spec = {
|
||||||
'parts': directives.nonnegative_int,
|
'parts': int,
|
||||||
'private-bases': directives.flag,
|
'private-bases': directives.flag,
|
||||||
'caption': directives.unchanged,
|
'caption': directives.unchanged,
|
||||||
'top-classes': directives.unchanged_required,
|
'top-classes': directives.unchanged_required,
|
||||||
|
Loading…
Reference in New Issue
Block a user