Merge pull request #603 from enjoy-digital/socdoc-extensions

Socdoc extensions
This commit is contained in:
Sean Cross 2020-07-24 16:42:23 +08:00 committed by GitHub
commit ed7211989f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -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']) 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 By default, `socdoc` unconditionally overwrites all files in the output
directory, including the sphinx `conf.py` file. To disable this feature directory, including the sphinx `conf.py` file. To disable this feature
so you can customize your own `conf.py` file, pass `from_scratch=False`: so you can customize your own `conf.py` file, pass `from_scratch=False`:

View File

@ -36,12 +36,13 @@ def generate_svd(soc, buildpath, filename=None, name="soc", **kwargs):
def generate_docs(soc, base_dir, def generate_docs(soc, base_dir,
project_name = "LiteX SoC Project", project_name = "LiteX SoC Project",
author = "Anonymous", author = "Anonymous",
sphinx_extensions = [], sphinx_extensions = [],
quiet = False, quiet = False,
note_pulses = False, note_pulses = False,
from_scratch = True): from_scratch = True,
sphinx_extra_config = ""):
"""Possible extra extensions: """Possible extra extensions:
[ [
'm2r', 'm2r',
@ -68,6 +69,7 @@ def generate_docs(soc, base_dir,
sphinx_ext_str += "\n \"{}\",".format(ext) sphinx_ext_str += "\n \"{}\",".format(ext)
print(default_sphinx_configuration.format(project_name, year, print(default_sphinx_configuration.format(project_name, year,
author, author, sphinx_ext_str), file=conf) author, author, sphinx_ext_str), file=conf)
print(sphinx_extra_config, file=conf)
if not quiet: if not quiet:
print("Generate the documentation by running `sphinx-build -M html {} {}_build`".format(base_dir, base_dir)) print("Generate the documentation by running `sphinx-build -M html {} {}_build`".format(base_dir, base_dir))