restructuredtext

Is there a way to create an intermediate output from Sphinx extensions?

久未见 提交于 2019-12-01 01:18:52
When sphinx processes an rst to html conversion is there a way to see an intermediate format after extensions have been processed? I am looking for an intermediate rst file that is generated after sphinx extensions were run. Any ideas? thanks pmoosh Take a look at the "ReST Builder" extension: https://pythonhosted.org/sphinxcontrib-restbuilder/ . There's not much to say; the extension takes reST as input and outputs ...drumroll... reST! Quote: This extension is in particular useful to use in combination with the autodoc extension. In this combination, autodoc generates the documentation based

Use Sphinx autosummary recursively to generate API documentation

廉价感情. 提交于 2019-12-01 00:23:03
问题 I want to use Sphinx's autosummary extension and templates to generate API docs recursively from docstrings. I want separate pages for each module, class, method, property and function. But it doesn't detect my templates at all. In fact, if I just remove the module.rst file from _templates/autosummary/ , it renders the whole file exactly the same way as before. I've followed this SO question to the letter. If you're interested, the full repository is on GitHub. Edit: It seems it does generate

Extract field list from reStructuredText

天大地大妈咪最大 提交于 2019-11-30 21:02:41
Say I have the following reST input: Some text ... :foo: bar Some text ... What I would like to end up with is a dict like this: {"foo": "bar"} I tried to use this: tree = docutils.core.publish_parts(text) It does parse the field list, but I end up with some pseudo XML in tree["whole"]? : <document source="<string>"> <docinfo> <field> <field_name> foo <field_body> <paragraph> bar Since the tree dict does not contain any other useful information and that is just a string, I am not sure how to parse the field list out of the reST document. How would I do that? Chris You can try to use something

Conditional toctree in Sphinx

浪子不回头ぞ 提交于 2019-11-30 20:52:03
I want to do multiple versions of a documentation, which differ in the sections that are included. To achieve this I would usually use either the only directive or the ifconfig extension. However, I cannot use any of those in combination with the toctree directive. What I basically want is something like this: .. toctree:: :maxdepth: 2 intro strings datatypes numeric .. only:: university complex Is there a way to do that? As far as I know there is no way to do what you would like. I have been struggling with the same issue, see https://github.com/sphinx-doc/sphinx/issues/1717 . The reason is

Part of a word bold in reStructuredText

五迷三道 提交于 2019-11-30 17:01:06
How can I make a part of a word bold in reStructuredText? Here is an example of what I need: ".rst stands for r e s tructured t ext." I was surprised that you could not simply write .rst stands for **r**e**s**tructured **t**ext. but the reStructuredText specification indeed states that inline markup must be followed by white-space or one of - . , : ; ! ? \ / ' " ) ] } or > , so the above string of reStructuredText is not valid. However, only a minor change is required to get valid character markup with backslash escapes. Changing the above to .rst stands for **r**\ e\ **s**\ tructured **t**\

What are some approaches to outputting a Python data structure to reStructuredText

假装没事ソ 提交于 2019-11-30 13:53:12
I have a list of tuples in Python that I would like to output to a table in reStructuredText. The docutils library has great support for converting reStructuredText to other formats, but I want to write directly from a data structure in memory to reStructuredText. I'm not aware of any libraries to output RST from python data structures, but it's pretty easy to format it yourself. Here's an example of formatting a list of python tuples to an RST table: >>> data = [('hey', 'stuff', '3'), ('table', 'row', 'something'), ('xy', 'z', 'abc')] >>> numcolumns = len(data[0]) >>> colsizes = [max(len(r[i]

ANTLR grammar for reStructuredText (rule priorities)

懵懂的女人 提交于 2019-11-30 13:33:08
问题 First question stream Hello everyone, This could be a follow-up on this question: Antlr rule priorities I'm trying to write an ANTLR grammar for the reStructuredText markup language. The main problem I'm facing is : "How to match any sequence of characters (regular text) without masking other grammar rules?" Let's take an example with a paragraph with inline markup: In `Figure 17-6`_, we have positioned ``before_ptr`` so that it points to the element *before* the insert point. The variable `

Overriding the default field name limit in sphinx/docutils

感情迁移 提交于 2019-11-30 06:59:05
I am using sphinx for generating html documentation for a project. I make extensive use of field lists . When generating html, each label/value pair is rendered as a single table row with two cells if the lenght of the label is at most 14 characters. If the label of one pair is longer than 14 characters, the label/values are rendered as two table rows. I want to increase the wrapping limit to a larger value (e.g. 40). I have found that the limit is controlled by the --field-name-limit option of docutils. However, I can't find how to set this value through sphinx. I have created a docutils.conf

How to document a module constant in Python?

∥☆過路亽.° 提交于 2019-11-30 06:39:47
问题 I have a module, errors.py in which several global constants are defined (note: I understand that Python doesn't have constants, but I've defined them by convention using UPPERCASE). """Indicates some unknown error.""" API_ERROR = 1 """Indicates that the request was bad in some way.""" BAD_REQUEST = 2 """Indicates that the request is missing required parameters.""" MISSING_PARAMS = 3 Using reStructuredText how can I document these constants? As you can see I've listed a docstring above them,

Italicize text containing a link

与世无争的帅哥 提交于 2019-11-30 05:08:51
I have an RST where I want an italicized link. However, the markup *Warning: `Watch this <http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e>`_!* renders in HTML as <em>Warning: `Watch this <http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e>`_!</em> That is, the italics render but the link doesn't. How do I get italics around the link? The problem is that reST markup cannot be nested. I managed to get it work with this: Warning: |text|_ .. _text: http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e .. |text| replace:: *Watch this* 来源: https://stackoverflow.com/questions/10669099/italicize-text