From dd366467ed5fd949d6ed1cf92ccfbc60e9b4def7 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 24 Jul 2020 16:01:54 +0800 Subject: [PATCH 1/2] litex: add `sphinx_extra_config` to `generate_docs()` This allows us to append additional strings to the sphinx `conf.py`. Signed-off-by: Sean Cross --- litex/soc/doc/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/litex/soc/doc/__init__.py b/litex/soc/doc/__init__.py index fe2f479fd..00097b5cc 100644 --- a/litex/soc/doc/__init__.py +++ b/litex/soc/doc/__init__.py @@ -36,12 +36,13 @@ def generate_svd(soc, buildpath, filename=None, name="soc", **kwargs): def generate_docs(soc, base_dir, - project_name = "LiteX SoC Project", - author = "Anonymous", - sphinx_extensions = [], - quiet = False, - note_pulses = False, - from_scratch = True): + project_name = "LiteX SoC Project", + author = "Anonymous", + sphinx_extensions = [], + quiet = False, + note_pulses = False, + from_scratch = True, + sphinx_extra_config = ""): """Possible extra extensions: [ 'm2r', @@ -68,6 +69,7 @@ def generate_docs(soc, base_dir, sphinx_ext_str += "\n \"{}\",".format(ext) print(default_sphinx_configuration.format(project_name, year, author, author, sphinx_ext_str), file=conf) + print(sphinx_extra_config, file=conf) if not quiet: print("Generate the documentation by running `sphinx-build -M html {} {}_build`".format(base_dir, base_dir)) From 29b2baf927fadc8d79b810157b0a5e2d6e0e4e2c Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 24 Jul 2020 16:03:24 +0800 Subject: [PATCH 2/2] doc: socdoc: document new `sphinx_extra_config` parameter This allows for appending additional configuration to `conf.py`. Signed-off-by: Sean Cross --- doc/socdoc.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/socdoc.md b/doc/socdoc.md index c565c54bb..5747c63b5 100644 --- a/doc/socdoc.md +++ b/doc/socdoc.md @@ -125,6 +125,21 @@ register listings. You can add additional modules by passing an array to generate_docs("build/documentation", sphinx_extensions=['sphinx.ext.mathjax']) ``` +You may need to pass additional configuration to `conf.py`. In this case, pass it +as `sphinx_extra_config`. For example: + +```python + generate_docs("build/documentation", + sphinx_extensions=['sphinx_math_dollar', 'sphinx.ext.mathjax'], + sphinx_extra_config=r""" + mathjax_config = { + 'tex2jax': { + 'inlineMath': [ ["\\(","\\)"] ], + 'displayMath': [["\\[","\\]"] ], + }, + }""") +``` + By default, `socdoc` unconditionally overwrites all files in the output directory, including the sphinx `conf.py` file. To disable this feature so you can customize your own `conf.py` file, pass `from_scratch=False`: