Skip to content

Commit

Permalink
Looking at all the files, I notice that you're using m2r2 to include …
Browse files Browse the repository at this point in the history
…the README.md file in your documentation, and there's quite a bit of complex markdown content in both README files, including tables, mermaid diagrams, and relative image paths.

The error occurs when trying to parse this content. Let's try a few fixes:
First, update your conf.py to explicitly set markdown support:
  • Loading branch information
endolith committed Nov 18, 2024
1 parent 8325028 commit b29f36e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
25 changes: 21 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'numpydoc',
'm2r2',
'sphinxcontrib.mermaid',
'recommonmark',
]

extlinks = {
Expand Down Expand Up @@ -70,6 +71,26 @@
'.md': 'markdown',
}

# Configure m2r2
source_parsers = {
'.md': 'm2r2.parser.MarkdownParser'
}

# Enable markdown support in RST
extensions.append('recommonmark')

# Configure recommonmark
import recommonmark
from recommonmark.transform import AutoStructify

def setup(app):
app.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'enable_math': True,
'enable_inline_math': True,
}, True)
app.add_transform(AutoStructify)
app.connect('build-finished', copy_examples)

# Copy ./examples/results images into documentation so they show up when
# markdown files with relative paths are transcluded (suggested by ChatGPT-4)
Expand All @@ -84,7 +105,3 @@ def copy_examples(app, docname):
if not os.path.exists(output_dir):
os.makedirs(os.path.join(app.outdir, 'examples'))
shutil.copytree(source_dir, output_dir)


def setup(app):
app.connect('build-finished', copy_examples)
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ numpydoc
m2r2
sphinxcontrib.mermaid
sphinx_rtd_theme
sphinxcontrib-apidoc
sphinxcontrib-apidoc
recommonmark

0 comments on commit b29f36e

Please sign in to comment.