python-sphinx

Managing Sphinx toctrees combined with inline sections

半城伤御伤魂 提交于 2021-02-20 04:51:14
问题 I'm trying to learn how I can manage a toctree element that is located in the same file as other content. Suppose I have a thingamajig.rst chapter that looks like this: Thingamajigs ============ .. toctree:: :maxdepth: 2 foo bar baz Overview ++++++++ Thingamajigs are fun When I render it --- foo/bar/baz have their own .rst files --- it looks like this: But if I move the Overview section before the toctree, then it pushes the toctree down into the Overview section: Thingamajigs ============

Sphinx autodoc functions within module

半腔热情 提交于 2021-02-18 12:42:14
问题 I am just getting started with sphinx and willing to learn. I would like to break up my various functions into different sections within my index.rst file. So each function has it's own header. So for example if I have a python file named test.py and within that file I have 2 functions: def foo(): """This prints bar""" print("bar") def bar(): """This prints foo""" print("foo") How could I within the index.rst separate the 2 functions within my test.py file? :mod:`test` -- foo .. automodule::

Custom Syntax Highlighting with Sphinx

蹲街弑〆低调 提交于 2021-02-18 05:24:44
问题 I am interested in creating a custom syntax highlighter that can be used in a Sphinx environment. Is this possible? If so how would I go about doing it? 回答1: Background Sphinx (http://sphinx-doc.org/) internally uses Pygments (http://pygments.org/) as a syntax highligher. Pygments supports adding custom syntax highlighter (lexer) as described here http://pygments.org/docs/lexerdevelopment/. Example usage I would try to define a new custom lexer in Pygments and initialize that new custom lexer

How to make toctree link refer to the separate file like it refers to the subsections

喜你入骨 提交于 2021-02-15 16:35:49
问题 Structure The following structure of the project: index.rst MyProject ========= Contents: .. toctree:: group1 group1.rst Group1 ------ Subgroup1 ========= Subgroup1 contents Subgroup2 ========= Subgroup2 contents Rendered to (after clicking on Group1 -> Subgroup2 ): As you can see it opens the Group1 page and linked to Subgroup2 section. Want I want to have the same on the left side ( Group1 openned and Subgroup2 choosed) but on the right side I want to see only Subgroup2 page (page without

How to make toctree link refer to the separate file like it refers to the subsections

﹥>﹥吖頭↗ 提交于 2021-02-15 16:33:32
问题 Structure The following structure of the project: index.rst MyProject ========= Contents: .. toctree:: group1 group1.rst Group1 ------ Subgroup1 ========= Subgroup1 contents Subgroup2 ========= Subgroup2 contents Rendered to (after clicking on Group1 -> Subgroup2 ): As you can see it opens the Group1 page and linked to Subgroup2 section. Want I want to have the same on the left side ( Group1 openned and Subgroup2 choosed) but on the right side I want to see only Subgroup2 page (page without

How to make toctree link refer to the separate file like it refers to the subsections

纵然是瞬间 提交于 2021-02-15 16:31:10
问题 Structure The following structure of the project: index.rst MyProject ========= Contents: .. toctree:: group1 group1.rst Group1 ------ Subgroup1 ========= Subgroup1 contents Subgroup2 ========= Subgroup2 contents Rendered to (after clicking on Group1 -> Subgroup2 ): As you can see it opens the Group1 page and linked to Subgroup2 section. Want I want to have the same on the left side ( Group1 openned and Subgroup2 choosed) but on the right side I want to see only Subgroup2 page (page without

Create automatic numbering for items in Sphinx reStructuredText

独自空忆成欢 提交于 2021-02-11 13:59:57
问题 I am preparing a training manual for which I have different types of activities. I am looking to have a way to automatically number them. Something like: Task 1, Task 2, Task n... I saw examples of how to create lists, but what I want is not quite the same. I guess I am looking for some kind of constructor that allows something like: 'description' + 'number' 来源: https://stackoverflow.com/questions/62936118/create-automatic-numbering-for-items-in-sphinx-restructuredtext

Create automatic numbering for items in Sphinx reStructuredText

☆樱花仙子☆ 提交于 2021-02-11 13:57:20
问题 I am preparing a training manual for which I have different types of activities. I am looking to have a way to automatically number them. Something like: Task 1, Task 2, Task n... I saw examples of how to create lists, but what I want is not quite the same. I guess I am looking for some kind of constructor that allows something like: 'description' + 'number' 来源: https://stackoverflow.com/questions/62936118/create-automatic-numbering-for-items-in-sphinx-restructuredtext

Show/hide part of text (question/answer) in sphinx file

喜你入骨 提交于 2021-02-11 13:38:15
问题 I was wondering if there is a method to add a directive to a sphinx document with a hidden section that can be opened with a click. Basically something like you can find https://realpython.com/pandas-python-explore-dataset/ (search for Show/Hide): 回答1: Here is a working example from the Mastering Plone Training documentation. And here's the source code. .. admonition:: Solution :class: toggle * Go to the dexterity-controlpanel (http://localhost:8080/Plone/@@dexterity-types) * Click on *Page*

Sphinx automodule, no text wrap in class name (latexpdf)

会有一股神秘感。 提交于 2021-02-10 22:42:19
问题 I'm generating pdf using make latexpdf of Sphinx. This mostly works fine but I have a quite deep folder structure for my project resulting in class names that do not fit on the page. Anyone who knows how I can tackle this? Here is a screenshot of the problem: 回答1: Hi I hope you found the solution if not add the code below in the preamble of your conf.py \makeatletter \renewcommand{\pysigline}[1]{% \setlength{\py@argswidth}{\dimexpr\labelwidth+\linewidth\relax}% \item[{\parbox[t]{\py@argswidth