Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx (documentation tool): set tab width in output

How do you set tab width in HTML output of Sphinx code snippets highlighted by Pygments? By default it is the annoying 8, but I want 4. Did not find a word about this setting in Sphinx conf.py.

like image 385
jbasko Avatar asked Nov 06 '09 10:11

jbasko


1 Answers

Add something like this to your conf.py:

import re

def process_docstring(app, what, name, obj, options, lines):
    spaces_pat = re.compile(r"( {8})")
    ll = []
    for l in lines:
        ll.append(spaces_pat.sub("    ",l))
    lines[:] = ll

def setup(app):
    app.connect('autodoc-process-docstring', process_docstring)

See also Sphinx Docstring preprocessing documentation.

like image 188
gieffe Avatar answered Nov 01 '22 04:11

gieffe