Questions tagged [docutils]

a general purpose document processing system written in Python.

Docutils is an open-source text processing system for processing plain text documentation into useful formats such as HTML, LaTeX, man-pages, open-document or XML. It includes the markup language.

The Docutils homepage may be found here.

180 questions
3
votes
0 answers

Docutils difference between text and rawsource in nodes.Text?

When creating new nodes such as nodes.title, one needs to provide two strings: rawsource text Often I see this: nodes.title('foobar', 'foobar', ids=[id]) Or sometime... nodes.target('', '') I don't understand why this repetition, and why it is…
nowox
  • 25,978
  • 39
  • 143
  • 293
3
votes
1 answer

How can I use an existing Directive within a custom python-sphinx Directive/extension?

I'd like to create a custom Directive that uses the an existing Directive (code-block in this example) in it's implementation. The manual equivalent of this in reStructuredText would be: .. mydirective:: py .. code-block: py …
David Foster
  • 447
  • 4
  • 16
3
votes
1 answer

Write reStructuredText t programmatically in Python

Is there any Python3.X library that helps to write rST file/text. I do not want to write rST file with manual styling with file.write(). I am looking for a library which makes it easier to create an rST file with different elements like bold,…
Kumar Roshan Mehta
  • 3,078
  • 2
  • 27
  • 50
3
votes
0 answers

How to unit test a sphinx/docutils directive

I have created a Sphinx extension containing a directive. Now I want to include unit tests before I start to refactor it. So using pytest I created a test file containing this fixture: wide_format =…
LNoor
  • 91
  • 4
3
votes
0 answers

Adding an HTML class to a Sphinx directive with an extension

I'm trying to write a basic extension to create a new directive (output) based on the only directive provided by Sphinx. This new directive simply needs to add an HTML class to the standard result of the Only directive. So for this I have tried the…
Flag
  • 497
  • 1
  • 3
  • 17
3
votes
0 answers

Custom sphinx role for references

I would like to create a sphinx role :config:`param` that appears as literal text config["param"] and at the same time is a link. I've a basic running version: def config_role(name, rawtext, text, lineno, inliner, options={}, content=[]): …
Tim Hoffmann
  • 1,325
  • 9
  • 28
3
votes
2 answers

removing docinfo in docutils output with HTML5 writer

With the docutils python library, when using the html5 writer, I cannot find a way not to have the docinfo (fields at the beginning of the source) included in the output. Here is a minimal example: import docutils.io, docutils.core SOURCE =…
Cédric Van Rompay
  • 2,489
  • 1
  • 18
  • 24
3
votes
2 answers

Python convert sphinx RST to HTML

I have tried this code: from docutils.core import publish_string text = publish_string(open(file_path, 'r').read(), writer_name='html') But it says:

Unknown directive type "toctree".

So it won't work with some specific sphinx…
StackUser
  • 243
  • 2
  • 19
3
votes
4 answers

How to add Google Analytics to reStructuredText?

I am using reStructured text to create some easy websites. So I have got a lot of *.rst files in which I want to add the Google Analytics code. But as far as I know it is not possible to add something like this?! I am using rst2html to convert the…
Mark
  • 7,507
  • 12
  • 52
  • 88
3
votes
1 answer

rst2html.py style sheet

Using Docutils's rst2html.py, is it possible to include a link to a stylesheet in the head: ......? So, to clarify, I'm not interested in generating