Repository: libcloud Updated Branches: refs/heads/trunk 9ddaa91f2 -> 30b11131f
Use different approach, using exclude_patterns breaks api docs on read the docs. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/30b11131 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/30b11131 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/30b11131 Branch: refs/heads/trunk Commit: 30b11131fc9cb88fb25648ceedff3f5edf36d567 Parents: 9ddaa91 Author: Tomaz Muraus <to...@tomaz.me> Authored: Sun Jan 3 21:46:16 2016 +0800 Committer: Tomaz Muraus <to...@tomaz.me> Committed: Sun Jan 3 21:46:16 2016 +0800 ---------------------------------------------------------------------- docs/conf.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/30b11131/docs/conf.py ---------------------------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index f1e53d8..c61e38e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,6 +13,7 @@ import os import sys +import glob import subprocess from sphinx.environment import BuildEnvironment @@ -20,13 +21,32 @@ from sphinx.environment import BuildEnvironment from sphinx.ext.autodoc import AutoDirective from sphinx.ext.autodoc import AutodocReporter +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +BASE_DIR = os.path.abspath(BASE_DIR) + # Detect if we are running on read the docs on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +api_docs_files = glob.glob(os.path.join(BASE_DIR, 'apidocs/') + '*.rst') if on_rtd: cmd = 'sphinx-apidoc -d 3 -o apidocs/ ../libcloud/' subprocess.call(cmd, shell=True) + # Hack, we can't use "exclude_patterns" since then api docs won't + # get published on readthedocs + api_docs_files = glob.glob(os.path.join(BASE_DIR, 'apidocs/') + '*.rst') + + for file_path in api_docs_files: + with open(file_path, 'r') as fp: + content = fp.read() + + if ':orphan:' in content: + continue + + new_content = ':orphan:\n\n' + content + with open(file_path, 'w') as fp: + fp.write(new_content) + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -80,7 +100,6 @@ release = '0.14.0-dev' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [ - 'apidocs/*', # generated during build (orphans) '_build', '*/_*.rst' ]