diff --git a/sphinx_astropy/conf.py b/sphinx_astropy/conf.py index 48db1e7..9210fb0 100644 --- a/sphinx_astropy/conf.py +++ b/sphinx_astropy/conf.py @@ -9,12 +9,13 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import re import warnings + from os import path from distutils.version import LooseVersion -import re -from ..utils.compat import subprocess +from ..compat import subprocess # -- General configuration ---------------------------------------------------- @@ -127,14 +128,14 @@ def get_graphviz_version(): 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.inheritance_diagram', - 'astropy.sphinx.ext.numpydoc', - 'astropy.sphinx.ext.astropyautosummary', - 'astropy.sphinx.ext.automodsumm', - 'astropy.sphinx.ext.automodapi', - 'astropy.sphinx.ext.tocdepthfix', - 'astropy.sphinx.ext.doctest', - 'astropy.sphinx.ext.changelog_links', - 'astropy.sphinx.ext.viewcode' # Use patched version of viewcode + 'astropy_helpers.sphinx.ext.numpydoc', + 'astropy_helpers.sphinx.ext.astropyautosummary', + 'astropy_helpers.sphinx.ext.automodsumm', + 'astropy_helpers.sphinx.ext.automodapi', + 'astropy_helpers.sphinx.ext.tocdepthfix', + 'astropy_helpers.sphinx.ext.doctest', + 'astropy_helpers.sphinx.ext.changelog_links', + 'astropy_helpers.sphinx.ext.viewcode' # Use patched version of viewcode ] # Above, we use a patched version of viewcode rather than 'sphinx.ext.viewcode' @@ -183,7 +184,10 @@ def get_graphviz_version(): # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = 'astropy_logo.ico' # included in the bootstrap-astropy theme + +# included in the bootstrap-astropy theme +html_favicon = path.join(html_theme_path[0], html_theme, 'static', + 'astropy_logo.ico') # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff --git a/sphinx_astropy/ext/changelog_links.py b/sphinx_astropy/ext/changelog_links.py index c928bba..4408547 100644 --- a/sphinx_astropy/ext/changelog_links.py +++ b/sphinx_astropy/ext/changelog_links.py @@ -16,46 +16,49 @@ def process_changelog_links(app, doctree, docname): - if 'changelog' in docname and app.config.github_issues_url is not None: - - for item in doctree.traverse(): - - if isinstance(item, Text): - - # We build a new list of items to replace the current item. If - # a link is found, we need to use a 'reference' item. - children = [] - - # First cycle through blocks of issues (delimited by []) then - # iterate inside each one to find the individual issues. - prev_block_end = 0 - for block in BLOCK_PATTERN.finditer(item): - block_start, block_end = block.start(), block.end() - children.append(Text(item[prev_block_end:block_start])) - block = item[block_start:block_end] - prev_end = 0 - for m in ISSUE_PATTERN.finditer(block): - start, end = m.start(), m.end() - children.append(Text(block[prev_end:start])) - issue_number = block[start:end] - children.append(reference(text=issue_number, - name=issue_number, - refuri=app.config.github_issues_url + issue_number[1:])) - prev_end = end - - prev_block_end = block_end - - # If no issues were found, this adds the whole item, - # otherwise it adds the remaining text. - children.append(Text(block[prev_end:block_end])) - - # If no blocks were found, this adds the whole item, otherwise - # it adds the remaining text. - children.append(Text(item[prev_block_end:])) - - # Replace item by the new list of items we have generated, - # which may contain links. - item.parent.replace(item, children) + if 'changelog' not in docname or app.config.github_issues_url is None: + return + + for item in doctree.traverse(): + + if not isinstance(item, Text): + continue + + # We build a new list of items to replace the current item. If + # a link is found, we need to use a 'reference' item. + children = [] + + # First cycle through blocks of issues (delimited by []) then + # iterate inside each one to find the individual issues. + prev_block_end = 0 + for block in BLOCK_PATTERN.finditer(item): + block_start, block_end = block.start(), block.end() + children.append(Text(item[prev_block_end:block_start])) + block = item[block_start:block_end] + prev_end = 0 + for m in ISSUE_PATTERN.finditer(block): + start, end = m.start(), m.end() + children.append(Text(block[prev_end:start])) + issue_number = block[start:end] + refuri = app.config.github_issues_url + issue_number[1:] + children.append(reference(text=issue_number, + name=issue_number, + refuri=refuri)) + prev_end = end + + prev_block_end = block_end + + # If no issues were found, this adds the whole item, + # otherwise it adds the remaining text. + children.append(Text(block[prev_end:block_end])) + + # If no blocks were found, this adds the whole item, otherwise + # it adds the remaining text. + children.append(Text(item[prev_block_end:])) + + # Replace item by the new list of items we have generated, + # which may contain links. + item.parent.replace(item, children) def setup(app):