Sphinx Documentation Generator's Option Parser
Richard Wilbur
richard.wilbur at gmail.com
Fri Jun 24 08:32:33 UTC 2016
Having taken a look at the sphinx source
/usr/lib/python2.7/dist-packages/sphinx
on my debian box, I found that in sphinx/domains/std.py there is a
regular expression defined for recognizing options. I believe I know
how to change it to allow the period character '.' in an option name:
Original:
# RE for option descriptions
option_desc_re = re.compile(r'((?:/|-|--)?[-_a-zA-Z0-9]+)(\s*.*)')
Allow '.' by adding '\.':
option_desc_re = re.compile(r'((?:/|-|--)?[-\._a-zA-Z0-9]+)(\s*.*)')
As far as I can tell this change should be sufficient. Since I am
trying to create something we could ship which only overrides this
regular expression, I haven't tried editing the distribution package
file. I have tried several different schemes to override/replace this
definition:
1. In plugins/en/conf.py I added:
import sphinx.domains.std
sphinx.domains.std.option_desc_re = \
re.compile(r'((?:/|-|--)?[-\._a-zA-Z0-9]+)(\s*.*)')
2. I copied /usr/lib/python2.7/dist-packages/sphinx into my branch
directory and changed the sphinx invocation in the plugins/en/Makefile
to:
PYTHONPATH=<branch directory> sphinx-build
3. I copied /usr/share/sphinx/scripts/python2/sphinx-build to my
branch directory, changed sphinx-build to insert <branch directory> at
the beginning of sys.path before importing anything from sphinx and
changed the sphinx invocation in the plugins/en/Makefile to:
PYTHONPATH=<branch directory> <branch directory>/sphinx-build
Unfortunately, none of these seem to have any effect. (Maybe my syntax is bad?)
For a proof of concept I guess I can go muck with the distribution
package sphinx code but that wasn't the way I was hoping to distribute
the fix.
I'm obviously missing something important. Wish I knew what it was.
Anybody have any bright ideas?
Sincerely,
Richard
More information about the bazaar
mailing list