Skip to content

Commit

Permalink
Added shim that allows us to use m2r components, but recommonmark mainly
Browse files Browse the repository at this point in the history
Also made some changes to makefile in line with latest sphinx (3.x)
config generation
  • Loading branch information
dotsdl committed May 19, 2020
1 parent 72ddc2b commit f2b4acd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
7 changes: 3 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = openforcefield
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

Expand All @@ -17,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 changes: 23 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import openforcefield

from recommonmark.transform import AutoStructify
from m2r import MdInclude

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -46,7 +49,7 @@
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'nbsphinx',
'm2r', # render markdown
'recommonmark', # render markdown
]

autosummary_generate = True
Expand Down Expand Up @@ -285,3 +288,22 @@
author, 'openforcefield', 'One line description of project.',
'Miscellaneous'),
]

# workaround for using m2r only for mdinclude and recommonmark for everything else
# m2r unmaintained, but has features that aren't easy to replicate in recommonmark
# https://github.com/readthedocs/recommonmark/issues/191#issuecomment-622369992
# credit: @orsinium
def setup(app):
config = {
'auto_toc_tree_section': 'Contents',
'enable_eval_rst': True,
}
app.add_config_value('recommonmark_config', config, True)
app.add_transform(AutoStructify)

# from m2r to make `mdinclude` work
app.add_config_value('no_underscore_emphasis', False, 'env')
app.add_config_value('m2r_parse_relative_links', False, 'env')
app.add_config_value('m2r_anonymous_references', False, 'env')
app.add_config_value('m2r_disable_inline_math', False, 'env')
app.add_directive('mdinclude', MdInclude)

0 comments on commit f2b4acd

Please sign in to comment.