python-sphinx

Execute code in autodoc docstring

会有一股神秘感。 提交于 2019-12-25 04:05:22
问题 When using Sphinx and autodoc to document a Python project, you can use :Example: to include a code sample in your module/class/function docstring, which Sphinx will kindly syntax highlight for you. Something like so. >>> rng = Range(0, 1000) >>> rng [0, 1000) >>> len(rng) 1000 >>> rng.start = 500 >>> rng.start 500 >>> rng.end 1000 >>> I copied and pasted this from the Python interpreter. Is there any way to have Sphinx or autodoc execute the code and capture the output automatically for the

Sphinx documentation and links to Markdown

孤者浪人 提交于 2019-12-25 03:59:07
问题 I'm trying to use Sphinx to build some documentation from Markdown source. My conf.py is as follows... conf.py from recommonmark.parser import CommonMarkParser project = 'DS' copyright = '2018, DS' author = 'DS, Work' version = '' release = '' extensions = [] templates_path = ['_templates'] source_suffix = ['.rst', '.md'] master_doc = 'index' language = None exclude_patterns = [] pygments_style = 'sphinx' html_theme = 'classic' html_static_path = ['_static'] source_parsers = { '.md':

Add table of methods in Sphinx documentation of a class

本秂侑毒 提交于 2019-12-25 01:42:45
问题 How can I automatically add a table with the list of the methods for a given class using Sphinx? Something like in the scikit-learn documentation (example): Thanks very much. Edit: Thank you very much mzjn! Thanks to autosummary , there is now a table with the description of the methods. However the layout is not very pretty: It looks better on the API file: There are dots when the list of parameters is too long. 来源: https://stackoverflow.com/questions/57977411/add-table-of-methods-in-sphinx

Can I use sphinx automodule but drop the module name in the signature?

时光总嘲笑我的痴心妄想 提交于 2019-12-25 00:56:42
问题 I have a module mod with some submodule submod and use .. automodule:: mod.submod to generate documentation for it. The signatures of the elements (functions, classes etc.) in the modules now look like mod.submod.my_function(*args, **kwargs) . I would instead like Sphinx to just show the name of the function, i.e. the signature my_function(*args, **kwargs) . Do I have any way to drop the leading module and submodules in the signature? 回答1: Yes, try this in docs/mod/submod.rst : .. automodule:

Automatic Python module documentation with Sphinx: add a table of content

人盡茶涼 提交于 2019-12-24 21:26:29
问题 I am using the automodule directive to document some Python module using Sphinx: .. automodule:: mymodule.mysubmodule :members: This works very well. However, I would like to include a sort of "table of content" of all the members to be documented this way. For example if mysubmodule contains classes A , B and C I would these displayed as a list above the details (with links). 来源: https://stackoverflow.com/questions/53371146/automatic-python-module-documentation-with-sphinx-add-a-table-of

Building HTML pages with sphinx

血红的双手。 提交于 2019-12-24 19:01:59
问题 I've come across an issue. I'm using sphinx to create my documentation. I've built the html pages. However, whenever I edit the html pages (add a css file, .js script and buttons) in my HTML editor, the changes don't stay when I do 'make html' in my terminal, and it just goes back to what it was before i added my own stuff in, if I do a hard refresh. Is there a way to make my editied html stay as they are? All I'm doing is editing text in my source files (.rst files in sphinx) and it's

GitHub links in Sphinx docs

喜夏-厌秋 提交于 2019-12-24 16:33:06
问题 Here's an example Sphinx doc: https://github.com/django-tastypie/django-tastypie/blob/v0.13.2/docs/release_notes/v0.13.2.rst I'd like commit SHA's, issue numbers, and @mentions to be hyperlinked. Anyway to do that automatically? 回答1: I'd suggest checking out the Sphinx Extension library at http://sphinxext-survey.readthedocs.org/en/latest/changelog-version-control.html. Specifically, I believe these two extensions may provide you at least some of the support you're looking for (sans the

sphinx autodoc-skip-member handler: can't show __init__() when using napoleon

二次信任 提交于 2019-12-24 15:37:44
问题 I want to include the docstrings for __init__() in my sphinx-generated documentation. I was following the accepted answer to this stackoverflow question to add a handler for autodoc-skip-member and was still unable to see my __init__() documentation. Trace code inside the if name == "__init__": block shows I am hitting that code. On a hunch I removed 'sphinx.ext.napoleon' from my extensions definition, leaving extensions = [ 'sphinx.ext.autodoc', # 'sphinx.ext.napoleon', ] and then I can see

How to force a file (mp4) to transfer from github to readthedocs

左心房为你撑大大i 提交于 2019-12-24 10:23:59
问题 I have a repository on github: https://github.com/springer-math/Mathematics-of-Epidemics-on-Networks Within it there is a file docs/SIR_2dgrid.mp4 which contains an animation I want to appear in the documentation at readthedocs (specifically at this page: http://epidemicsonnetworks.readthedocs.io/en/latest/Simulation_Investigation.html) Additionally, there is a file docs/Simulation_Investigation.rst which codes that page and tries to refer to that mp4. I've tried lots of variants (attempting

Failed to import module when building the sphinx documentation

会有一股神秘感。 提交于 2019-12-24 09:38:30
问题 I'm using Sphinx version 1.4.5 . My project structure is the following: + src > main.py + docs (generated with sphinx-quickstart) Even after adding the path to the src folder in docs/conf.py : sys.path.insert(0, os.path.abspath('../src')) And generating the rst file for src/main.py (i.e. docs/src.rst and docs/modules.rst ) with: $ sphinx-apidoc -fo docs src When I try to build the html webpages with: $ make clean $ make html It couldn't find both the src module and src/main.py : WARNING: