python-sphinx

Creating a literal text block in Sphinx

心已入冬 提交于 2021-02-09 11:12:38
问题 I would like to make a directory tree in a docstring and have it rendered without change to my Sphinx documentation, but I am having trouble. I have tried using: single, double, and triple back-ticks; literal :code: ; and literal .. code-block:: python to get this to work. I imagine the latter two did not work because this block is also not valid Python/code. In addition I have varied the number and type of indentation and spacing, to no avail. My example (using three back-ticks to delineate

sphinx autodoc for python doesn't show anything (on readthedocs)

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-09 11:01:17
问题 I have this python package that I'd like to automatically document using Sphinx. I've inserted docstrings in every functions and classes. I made an account on ReadTheDocs, and did the setup accordingly (i.e., a docs/ dir with a conf.py file). Then, basically, I've tried almost everything: every combination of autodoc:: , autofunction:: , autoclass:: ; I tried using the same conf.py file as other packages which documented API (with specific changes made according to my case, of course); but it

How can I document a function which takes a function as a parameter with Sphinx?

我们两清 提交于 2021-02-08 17:24:42
问题 Let's say I have a class which looks something like this: class FunctionCaller: def __init__(self): """A class which can be used to call different functions which take the same parameters """ self.f = lambda a,b: (a,b) def setF(self, new_f): """Set the function to call :param new_f: The new function this object should call :type new_f: func(:class:`.SomeClass`, :class:`int`) """ self.f = new_f def callF(self, a, b): """Call the function this object currently contains :param a: Some value

Sphinx Pygments lexer filter extension?

南楼画角 提交于 2021-02-08 15:37:13
问题 I have a Lisp-like language I would like to highlight using Pygments in Sphinx code snippet documentation. My approach is to extend the existing CommonLispLexer to add the built-in names using a NameHighlightFilter. However, it is not working, so I must be missing something obvious. I have added the following to my conf.py: def setup(app): from sphinx.highlighting import lexers from pygments.lexers import CommonLispLexer from pygments.token import Name from pygments.filters import

How can I show inherited members of a class in my Sphinx documentation?

穿精又带淫゛_ 提交于 2021-02-08 12:45:55
问题 I want to document some classes which all derive from the same base class with some common attributes and I would like to repeat the documentation for every attribute in the subclasses, so that I can see all the attributes for a class in a single place. So for instance I have this code: class Base(object): """Base class.""" #: First attribute a = int #: Second attribute b = str class FirstChild(Base): """First Child of Base.""" #: Child attribute c = float class SecondChild(Base): """Second

How can I show inherited members of a class in my Sphinx documentation?

本小妞迷上赌 提交于 2021-02-08 12:45:15
问题 I want to document some classes which all derive from the same base class with some common attributes and I would like to repeat the documentation for every attribute in the subclasses, so that I can see all the attributes for a class in a single place. So for instance I have this code: class Base(object): """Base class.""" #: First attribute a = int #: Second attribute b = str class FirstChild(Base): """First Child of Base.""" #: Child attribute c = float class SecondChild(Base): """Second

Using Python docstring override and extend verbs in Sphinx

时光总嘲笑我的痴心妄想 提交于 2021-02-08 09:46:11
问题 I am using Sphinx to generate documentation from my docstrings, which are formatted in the Sphinx style. According to PEP-257 I should be using the verb "override" and "extend" to indicate if inherited methods are replaced or called. If a class subclasses another class and its behavior is mostly inherited from that class, its docstring should mention this and summarize the differences. Use the verb "override" to indicate that a subclass method replaces a superclass method and does not call

How to create referenceable label node above section in sphinx

大兔子大兔子 提交于 2021-02-08 09:17:37
问题 I am creating a custom directive in sphinx. This directive lists all possible objects (each one in separate section). Now I would like those objects to be referenceable from other parts (files) of documentation. I was trying to do something very simple like: class MyDirective(Directive): def run(self, obj): id1 = 'object-unique-id1' id2 = 'object-unique-id2' label = nodes.label('abc1', refid=id1) section = nodes.section(ids=[id2]) section += nodes.title(text='abc') section += label return

When using Sphinx, how can I document members that don't have docstrings?

被刻印的时光 ゝ 提交于 2021-02-08 08:37:17
问题 I'm writing documentation for package I've published, and I find the more thorough your documentation, the easier people find your package to use (duh). I'm actually having a lot of fun lovingly writing up all the features and details of my code. However, I'm completely flummoxed by how to write Sphinx-compatible documentation for class-level variables. In particular, I've got some enum classes I'd like to document, but for the life of me I can't figure out a way to attach documentation to

sphinx-apidoc picks up submodules, but autodoc doesn't document them

懵懂的女人 提交于 2021-02-07 14:19:27
问题 I've been working on a project for PyQt5 ( found here: https://github.com/MaVCArt/StyledPyQt5 ) which uses a package structure to make imports a bit more logical. I've been relatively successful in documenting the code so far with Sphinx, at least up until I introduced the package structure. ( before, everything was in one folder ) The following is the problem: when I run sphinx-apidoc, everything runs fine, no errors. What's more, autodoc picks up all my submodules just fine. This is the