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
7
votes
1 answer

Sphinx: how to cross-reference a target generated by a custom directive

I'm having trouble cross-referencing a section generated by a custom directive. Here is the directive: from docutils import nodes from docutils.parsers import rst class TestDirective(rst.Directive): has_content = False required_arguments…
abey
  • 593
  • 10
  • 26
7
votes
2 answers

docutils/sphinx custom directive creating sibling section rather than child

Consider a reStructuredText document with this skeleton: Main Title ========== text text text text text Subsection ---------- text text text text text .. my-import-from:: file1 .. my-import-from:: file2 The my-import-from directive is provided…
zwol
  • 135,547
  • 38
  • 252
  • 361
7
votes
3 answers

Resolve Substitutions in RestructuredText

I want to take the following restructured text snippet that contains a substitution definition: text = """ |python| .. |python| image:: python.jpg """ And resolve the definitions so the substitution text is displayed: resolved_text = """ ..…
geographika
  • 6,458
  • 4
  • 38
  • 56
6
votes
1 answer

Sphinx domain for Clojure

I'm used to working with Sphinx for C++ and Python projects. I've just started a project in Clojure and I'd like to re-use my Sphinx/reStructuredText skills to document my Clojure code. Since there's no built-in domain for Clojure, I started…
André Caron
  • 44,541
  • 12
  • 67
  • 125
6
votes
1 answer

Docutils: traverse sections?

How can I traverse each of the section names of a document in Sphinx? (and where is the documentation for docutils? It is maddeningly difficult to find anything useful beyond the Sphinx Application API; even looking at the source code for…
Jason S
  • 184,598
  • 164
  • 608
  • 970
6
votes
1 answer

Multiple translations in a single reStructuredtext file

Is there a way to achieve the following? Source is a single .rst file where the translation in multiple languages coexist Generate web page renditions per language (in .html files preferably). This can be either a single file where readers can…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
6
votes
1 answer

Nesting Sphinx extension directives with reST

I'm trying to figure out if there's a way to nest Sphinx extension directives. I have a few custom node types that are working great, but I'd like a little more flexibility in the HTML I'm generating. Here's an example of what I'm trying to…
Isaac Dontje Lindell
  • 3,246
  • 6
  • 24
  • 35
6
votes
1 answer

parsing rST to HTML on the fly using Docutils

I want to parse .rst files to .html files on the fly to display as a webpage. I'm using pyramid, and I haven't found any quick help on how to use docutils inside python code and make it write to a buffer. Anyone have any links to a simple tutorial…
xcorat
  • 1,434
  • 2
  • 17
  • 34
6
votes
1 answer

Sphinx Documentation, numbered figure references

I'm trying to get numbered figures to work on my Sphinx documentation project using latexpdf output. I installed the Sphinx numfig.py extension found here https://bitbucket.org/arjones6/sphinx-numfig However, whenever I use the :num: tag that is…
John Lotacs
  • 1,184
  • 4
  • 20
  • 34
6
votes
3 answers

Extract field list from reStructuredText

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…
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
5
votes
3 answers

reStructuredText not respecting subheadings

Here's a simple reST snippet: deleting this line causes all subheadings to be rendered as h1 tags I should be an h1 ================= I should be an h2 ----------------- foo I should also be an h2 ---------------------- foo and…
Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
5
votes
1 answer

How to create simple html tags with Python docutils

I'm working on a library for Pelican, for which I'm currently using reStructuredText and docutils. What I'm trying to do is create a custom directive that should output html. The html I want to output is:
Johan Vergeer
  • 5,208
  • 10
  • 48
  • 105
5
votes
1 answer

How do I convert a docutils document tree into an HTML string?

I'm trying to use the docutils package to convert ReST to HTML. This answer succinctly uses the docutils publish_* convenience functions to achieve this in one step. The ReST documents that I want to convert have multiple sections that I want to…
dsclose
  • 556
  • 5
  • 15
5
votes
2 answers

extract code from code directive from restructuredtext using docutils

I would like to extract out the source code verbatim from code directives in a restructuredtext string. What follows is my first attempt at doing this, but I would like to know if there is a better (i.e. more robust, or more general, or more…
mjandrews
  • 2,392
  • 4
  • 22
  • 39
5
votes
1 answer

Extending rst container to output extra div attributes

I'm starting to use pelican with reStructuredText rst page format. I have custom javascript (jQuery) things that I'd like to control with div attributes like data-default-tpl="basename" with nested content. What to extend and what. I've looked at…
Manwe
  • 401
  • 2
  • 11
1
2
3
11 12