restructuredtext

Add a class to a table in Sphinx?

馋奶兔 提交于 2019-11-28 12:16:53
I have a table in rst, and I want to add a class to it, when compiling to HTML with Sphinx. According to the docs , adding a .. class:: directive before the table should add the class to the table, but instead it adds a definition list. The table code is: .. class:: special == == == a b c 1 2 3 == == == which results in: <dl class="class"> <dt id="special"> <em class="property">class </em><code class="descname">special</code><a class="headerlink" href="#special" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <table border="1" class="docutils"> <colgroup> <col width="33%" />

How to ensure that README.rst is valid?

久未见 提交于 2019-11-28 11:19:51
There are two version of my little tool: https://pypi.python.org/pypi/tbzuploader/2017.11.0 https://pypi.python.org/pypi/tbzuploader/2017.12.0 Bug: The pypi page looks ugly. In the last update a change in README.rst cases a warning: user@host> rst2html.py README.rst > /tmp/foo.html README.rst:18: (WARNING/2) Inline emphasis start-string without end-string. README.rst:18: (WARNING/2) Inline emphasis start-string without end-string. Now the pypi page looks ugly :-( I use this recipe to do CI, bumpversion, upload to pypi: https://github.com/guettli/github-travis-bumpversion-pypi How could I

How to parse restructuredtext in python?

我与影子孤独终老i 提交于 2019-11-28 09:47:42
Is there any module that can parse restructuredtext into a tree model? Can docutils or sphinx do this? Gareth Latty Docutils does indeed contain the tools to do this. What you probably want is the parser at docutils.parsers.rst See this page for details on what is involved. There are also some examples at docutils/examples.py - particularly check out the internals() function, which is probably of interest. I'd like to extend upon the answer from Gareth Latty. "What you probably want is the parser at docutils.parsers.rst " is a good starting point of the answer, but what's next? Namely: How to

Render output from markdown file inside .rst file

旧时模样 提交于 2019-11-28 07:44:42
问题 I am using Sphinx for documenting a Python project and would like to have content from an existing .md file display inside of a .rst file. ( I have already set up my conf.py to allow for markdown). For example, I have a file called tutorial.md . I also have a .rst file as follows: ml == w2v ^^^ .. automodule:: package.ml.w2v :members: I would like be able to include a link to tutorial.md as follows, such that the content of tutorial.md will display in the file upon rendering. This can be

Python Sphinx referencing long names

与世无争的帅哥 提交于 2019-11-28 07:20:48
问题 I'm working on documentation for my Python module (using Sphinx and reST), and I'm finding that when cross-referencing other Python objects (modules, classes, functions, etc) the full object name ends up being incredibly long. Often it is longer than 80 characters, which I would like to avoid at all costs. Here is an example: def exampleFunction(): '''Here is an example docstring referencing another :class:`module1.module2.module3.module4.module5.ReallyLongExampleClassName` ''' The issue is

How to handle two dashes in ReST

吃可爱长大的小学妹 提交于 2019-11-28 07:18:00
问题 I'm using Sphinx to document a command line utility written in Python. I want to be able to document a command line option, such as --region like this: **--region** <region_name> in ReST and then use Sphinx to to generate my HTML and man pages for me. This works great when generating man pages but in the generated HTML, the -- gets turned into - which is incorrect. I have found that if I change my source ReST document to look like this: **---region** <region_name> The HTML generates correctly

Sphinx: Resume list numbering after a note section

廉价感情. 提交于 2019-11-28 02:58:37
问题 Consider the following list in ReStructuredText: Broken list example ------------------- #. First do spam #. Then do ``eggs`` .. note:: Nobody expects the Spanish Inquisistion #. The list restarts after the note When the list is compiled in Sphinx, the number after the note are reset to 1 : Any idea how to continue the numbered list after a note section? 回答1: The discontinuity of the list is caused by the note being a standalone element, not a child of the second numbered list element. To

Inline code highlighting in reStructuredText

痞子三分冷 提交于 2019-11-28 02:50:36
I know reStructuredText has this directive: .. code:: bash gedit pohl.m which renders a code block. Is there some way to get syntax highlighting for inline snippets like this: Do edit the file, type ``gedit pohl.m`` into a terminal. The backticks mark it as code, but I'd like to highlight it with pygments like the block. Is this possible? Chris Having looked into this some more I stumbled upon the document reStructuredText Interpreted Text Roles . From this document: Interpreted text uses backquotes (`) around the text. An explicit role marker may optionally appear before or after the text,

How do I set up custom styles for reStructuredText, Sphinx, ReadTheDocs, etc.?

匆匆过客 提交于 2019-11-28 00:47:58
I want to extend the theme used by Sphinx and ReadTheDocs with my own custom styles. What is the best way I can do this so that my changes will stick? Assumptions Your RTD doc set has something like the following structure: (root path) (some other stuff not germane to this discussion) _static/ _templates/ conf.py You're also building locally using sphinx-build or sphinx-autobuild using the default theme, but your deployed server might use the sphinx-rtd-theme instead. Use Case: Hatnotes For this illustration, I'm going to show how to create custom styling for "hatnotes", a concept which is

How do I create a global role/roles in Sphinx?

早过忘川 提交于 2019-11-27 19:48:15
This is a followup of "ReST Strikethrough" ReST strikethrough but in a Sphinx rather than ReST context. My question is whether there is a central place in sphinx where to put a "role" directive or whether this directive really has to be repeated in every rst file within a sphinx docmentation. In more detail: It is easy to define custom CSS styles for inline text (see ReST Strikethrough as example) using a role directive: .. role:: custom :class: custom This is an :custom:`inline text`. which translates into a html rendering of .. This is an <span class="custom">inline text</span>. .. Also, a