restructuredtext

How to convert reStructuredText to plain text

倖福魔咒の 提交于 2019-12-19 12:41:15
问题 I plan to use reStructuredText to write documentation with the main purpose of generating some nice HTML pages. For this I use the docutils rst2html.py tool. However, I may also need to present the documentation in nice plain text format, that is without the reStructuredText markup, and where paragraph wrapping and similar nice formatting is still performed on the text output. But, there is no rst2txt.py tool in the docutils. Is there a way to convert reStructuredText to nice plain text

How can I get rst2html.py to include the CSS for syntax highlighting?

泪湿孤枕 提交于 2019-12-19 07:02:53
问题 When I run rst2html.py against my ReStructured Text source, with its code-block directive, it adds all the spans and classes to the bits of code in the HTML, but the CSS to actually colorize those spans is absent. Is it possible to get RST to add a CSS link or embed the CSS in the HTML file? 回答1: As of Docutils 0.9 you could use the code directive. From the example on this page: .. code:: python def my_function(): "just a test" print 8/2 Alternatively, you can use Pygments for syntax

How can I get rst2html.py to include the CSS for syntax highlighting?

て烟熏妆下的殇ゞ 提交于 2019-12-19 07:02:23
问题 When I run rst2html.py against my ReStructured Text source, with its code-block directive, it adds all the spans and classes to the bits of code in the HTML, but the CSS to actually colorize those spans is absent. Is it possible to get RST to add a CSS link or embed the CSS in the HTML file? 回答1: As of Docutils 0.9 you could use the code directive. From the example on this page: .. code:: python def my_function(): "just a test" print 8/2 Alternatively, you can use Pygments for syntax

Extract field list from reStructuredText

六眼飞鱼酱① 提交于 2019-12-19 03:13:08
问题 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

Prevent sub-section nesting in Python Sphinx when using toctree

白昼怎懂夜的黑 提交于 2019-12-18 19:08:15
问题 I'm running into a problem in structuring my Sphinx users guide. I would like to form a chapter by having a main landing page (index.rst) that contains the chapter heading and an overview, and then separate sub-sections contained in different files(part1.rst, part2.rst). I am trying to use "toctree" to insert the separate subsections, but I am running into a nesting problem where my toctree is getting sucked into my overview section. (note: I am not using the ..include:: directive because I

标准的Python文档字符串格式是什么? [关闭]

痴心易碎 提交于 2019-12-18 17:15:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 已关闭 。 这个问题是基于意见的。 它当前不接受答案。 了解更多 。 想改善这个问题吗? 更新问题,以便通过 编辑此帖子 以事实和引用的形式回答。 去年 关闭。 我已经看到了几种用Python编写文档字符串的不同样式,是否有正式的或“同意的”样式? #1楼 是Python; 一切顺利 。 考虑如何 发布您的文档 。 除了您的源代码读者以外,文档字符串是不可见的。 人们真的很喜欢浏览和搜索网络上的文档。 为此,请使用文档工具 Sphinx 。 这是记录Python项目的实际标准。 该产品非常漂亮-请看 https://python-guide.readthedocs.org/en/latest/ 。 “ 阅读文档 ”网站将免费托管您的文档。 #2楼 显然没有人提到它:您还可以使用 Numpy Docstring Standard 。 它在科学界被广泛使用。 numpy 格式 的 说明以及 示例 您有一个狮身人面像扩展程序来渲染它: numpydoc 还有一个呈现的文档字符串看起来如何美丽的示例: http : //docs.scipy.org/doc/numpy/reference/generation/numpy.mean.html 用于解析Google样式文档字符串的Napolean狮身人面像扩展名(在

Have the same README both in Markdown and reStructuredText

走远了吗. 提交于 2019-12-18 09:54:14
问题 I have a project hosted on GitHub. For this I have written my README using the Markdown syntax in order to have it nicely formatted on GitHub. As my project is in Python I also plan to upload it to PyPi. The syntax used for READMEs on PyPi is reStructuredText. I would like to avoid having to handle two READMEs containing roughly the same content; so I searched for a markdown to RST (or the other way around) translator, but couldn't find any. The other solution I see is to perform a markdown

Substitutions inside links in reST / Sphinx

本秂侑毒 提交于 2019-12-17 22:43:34
问题 I am using Sphinx to document a webservice that will be deployed in different servers. The documentation is full of URL examples for the user to click and they should just work. My problem is that the host, port and deployment root will vary and the documentation will have to be re-generated for every deployment. I tried defining substitutions like this: |base_url|/path .. |base_url| replace:: http://localhost:8080 But the generated HTML is not what I want (doesn't include "/path" in the

Add a class to a table in Sphinx?

拟墨画扇 提交于 2019-12-17 20:35:47
问题 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

How to ensure that README.rst is valid?

空扰寡人 提交于 2019-12-17 19:23:52
问题 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,