Skip to content

Commit

Permalink
add hacky workaround for sphinx-doc/sphinx#3860
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Jun 15, 2017
1 parent d032853 commit d3f855a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
0.1.1
-----

* Add hack to ``docs/source/conf.py`` as workaround for https://github.com/sphinx-doc/sphinx/issues/3860
* Add TravisCI testing for py36

0.1.0 (2016-12-04)
Expand Down
26 changes: 24 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import sys
import os
import re
import logging
import types
# to let sphinx find the actual source...
sys.path.insert(0, os.path.abspath("../.."))
from versionfinder.version import VERSION
Expand Down Expand Up @@ -307,17 +309,37 @@
r'https?://testpypi\.python\.org/pypi/versionfinder'
]


# exclude module docstrings - see http://stackoverflow.com/a/18031024/211734
def remove_module_docstring(app, what, name, obj, options, lines):
if what == "module":
del lines[:]


# ignore non-local image warnings
def _warn_node(self, msg, node, **kwargs):
if not msg.startswith('nonlocal image URI found:'):
self._warnfunc(msg, '%s:%s' % get_source_line(node))
if msg.startswith('nonlocal image URI found:'):
return
self._warnfunc(msg, '%s:%s' % get_source_line(node))

sphinx.environment.BuildEnvironment.warn_node = _warn_node


# BEGIN workaround for https://github.com/sphinx-doc/sphinx/issues/3860
def _images_log_warning(self, msg, *args, **kwargs):
if msg.startswith(
'Could not fetch remote image: '
'https://readthedocs.org/projects/versionfinder/badge/?'
):
print('Suppressing RTD badge remote image warning: %s' % msg)
return
self._orig_warning(msg, *args, **kwargs)

img_log = logging.getLogger('sphinx.transforms.post_transforms.images')
img_log._orig_warning = img_log.warning
img_log.warning = types.MethodType(_images_log_warning, img_log)
# END workaround for https://github.com/sphinx-doc/sphinx/issues/3860


def setup(app):
app.connect("autodoc-process-docstring", remove_module_docstring)

0 comments on commit d3f855a

Please sign in to comment.