/usr/lib/python2.7/dist-packages/sphinx/ext/autosectionlabel.py is in python-sphinx 1.4.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # -*- coding: utf-8 -*-
"""
sphinx.ext.autosectionlabel
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allow reference sections by :ref: role using its title.
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from docutils import nodes
from sphinx.util.nodes import clean_astext
def register_sections_as_label(app, document):
labels = app.env.domaindata['std']['labels']
anonlabels = app.env.domaindata['std']['anonlabels']
for node in document.traverse(nodes.section):
name = nodes.fully_normalize_name(node[0].astext())
labelid = node['ids'][0]
docname = app.env.docname
sectname = clean_astext(node[0])
if name in labels:
app.env.warn_node('duplicate label %s, ' % name + 'other instance '
'in ' + app.env.doc2path(labels[name][0]), node)
anonlabels[name] = docname, labelid
labels[name] = docname, labelid, sectname
def setup(app):
app.connect('doctree-read', register_sections_as_label)
|