Changeset View
Changeset View
Standalone View
Standalone View
swh/docs/sphinx/conf.py
Show All 14 Lines | |||||
# Add any Sphinx extension module names here, as strings. They can be | # Add any Sphinx extension module names here, as strings. They can be | ||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||||
# ones. | # ones. | ||||
extensions = ['sphinx.ext.autodoc', | extensions = ['sphinx.ext.autodoc', | ||||
'sphinx.ext.napoleon', | 'sphinx.ext.napoleon', | ||||
'sphinxcontrib.httpdomain', | 'sphinxcontrib.httpdomain', | ||||
'sphinx.ext.extlinks', | 'sphinx.ext.extlinks', | ||||
'sphinxcontrib.images', | 'sphinxcontrib.images', | ||||
'sphinx.ext.viewcode', | |||||
] | ] | ||||
# Add any paths that contain templates here, relative to this directory. | # Add any paths that contain templates here, relative to this directory. | ||||
templates_path = ['_templates'] | templates_path = ['_templates'] | ||||
# The suffix(es) of source filenames. | # The suffix(es) of source filenames. | ||||
# You can specify multiple suffix as a list of string: | # You can specify multiple suffix as a list of string: | ||||
# | # | ||||
source_suffix = ['.rst', '.md'] | source_suffix = ['.rst', '.md'] | ||||
# source_suffix = '.rst' | # source_suffix = '.rst' | ||||
source_parsers = { | source_parsers = { | ||||
'.md': 'recommonmark.parser.CommonMarkParser', | '.md': 'recommonmark.parser.CommonMarkParser', | ||||
} | } | ||||
# The master toctree document. | # The master toctree document. | ||||
master_doc = 'index' | master_doc = 'index' | ||||
# A string of reStructuredText that will be included at the beginning of every | # A string of reStructuredText that will be included at the beginning of every | ||||
# source file that is read. | # source file that is read. | ||||
# A bit hackish but should work both for each swh package and the whole swh-doc | |||||
rst_prolog = ''' | rst_prolog = ''' | ||||
.. include:: /swh_substitutions | .. include:: /../../swh-docs/docs/swh_substitutions | ||||
''' | ''' | ||||
# The version info for the project you're documenting, acts as replacement for | # The version info for the project you're documenting, acts as replacement for | ||||
# |version| and |release|, also used in various other places throughout the | # |version| and |release|, also used in various other places throughout the | ||||
# built documents. | # built documents. | ||||
# | # | ||||
# The short X.Y version. | # The short X.Y version. | ||||
version = '' | version = '' | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
# for the extlinks extension, sub-projects should fill that dict | # for the extlinks extension, sub-projects should fill that dict | ||||
extlinks = {} | extlinks = {} | ||||
# hack to set the adequate django settings when building global swh doc | # hack to set the adequate django settings when building global swh doc | ||||
# to avoid build errors | # to avoid build errors | ||||
def source_read_handler(app, docname, source): | def source_read_handler(app, docname, source): | ||||
if 'swh-deposit' in docname: | |||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', | os.environ.setdefault('DJANGO_SETTINGS_MODULE', | ||||
'swh.deposit.settings.development') | 'swh.docs.django_settings') | ||||
django.setup() | |||||
elif 'swh-web' in docname: | |||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', | |||||
'swh.web.settings.development') | |||||
django.setup() | django.setup() | ||||
anlambert: The django setup can be moved in the `setup` function.
This way it will be called only once… | |||||
def setup(app): | def setup(app): | ||||
app.connect('source-read', source_read_handler) | app.connect('source-read', source_read_handler) |
The django setup can be moved in the setup function.
This way it will be called only once instead of each time a rst source file has been read