diff options
| author | Ask Solem <ask@celeryproject.org> | 2016-10-27 16:15:40 -0700 |
|---|---|---|
| committer | Ask Solem <ask@celeryproject.org> | 2016-10-27 16:15:40 -0700 |
| commit | 5d91ef3dbeaea5aa3d350105aba8bd49df69d483 (patch) | |
| tree | 2085133d3f2a49afb3ba6abb763162bc9ed62177 /docs/_ext | |
| parent | ded6f0c873201ab8a20ac3a1c453f891878e74d8 (diff) | |
| download | kombu-5d91ef3dbeaea5aa3d350105aba8bd49df69d483.tar.gz | |
Doc fixes
Diffstat (limited to 'docs/_ext')
| -rw-r--r-- | docs/_ext/.keep | 0 | ||||
| -rw-r--r-- | docs/_ext/githubsphinx.py | 110 |
2 files changed, 0 insertions, 110 deletions
diff --git a/docs/_ext/.keep b/docs/_ext/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/docs/_ext/.keep diff --git a/docs/_ext/githubsphinx.py b/docs/_ext/githubsphinx.py deleted file mode 100644 index 240c092f..00000000 --- a/docs/_ext/githubsphinx.py +++ /dev/null @@ -1,110 +0,0 @@ -"""Stolen from sphinxcontrib-issuetracker. - -Had to modify this as the original will make one Github API request -per issue, which is not at all needed if we just want to link to issues. - -""" -from __future__ import absolute_import, unicode_literals - -import re -import sys - -from collections import namedtuple - -from docutils import nodes -from docutils.transforms import Transform -from sphinx.roles import XRefRole -from sphinx.addnodes import pending_xref - -URL = 'https://github.com/{project}/issues/{issue_id}' - -Issue = namedtuple('Issue', ('id', 'title', 'url')) - -if sys.version_info[0] == 3: - str_t = text_t = str -else: - str_t = basestring - text_t = unicode - - -class IssueRole(XRefRole): - innernodeclass = nodes.inline - - -class Issues(Transform): - default_priority = 999 - - def apply(self): - config = self.document.settings.env.config - github_project = config.github_project - issue_pattern = config.github_issue_pattern - if isinstance(issue_pattern, str_t): - issue_pattern = re.compile(issue_pattern) - for node in self.document.traverse(nodes.Text): - parent = node.parent - if isinstance(parent, (nodes.literal, nodes.FixedTextElement)): - continue - text = text_t(node) - new_nodes = [] - last_issue_ref_end = 0 - for match in issue_pattern.finditer(text): - head = text[last_issue_ref_end:match.start()] - if head: - new_nodes.append(nodes.Text(head)) - last_issue_ref_end = match.end() - issuetext = match.group(0) - issue_id = match.group(1) - refnode = pending_xref() - refnode['reftarget'] = issue_id - refnode['reftype'] = 'issue' - refnode['github_project'] = github_project - reftitle = issuetext - refnode.append(nodes.inline( - issuetext, reftitle, classes=['xref', 'issue'])) - new_nodes.append(refnode) - if not new_nodes: - continue - tail = text[last_issue_ref_end:] - if tail: - new_nodes.append(nodes.Text(tail)) - parent.replace(node, new_nodes) - - -def make_issue_reference(issue, content_node): - reference = nodes.reference() - reference['refuri'] = issue.url - if issue.title: - reference['reftitle'] = issue.title - reference.append(content_node) - return reference - - -def resolve_issue_reference(app, env, node, contnode): - if node['reftype'] != 'issue': - return - issue_id = node['reftarget'] - project = node['github_project'] - - issue = Issue(issue_id, None, URL.format(project=project, - issue_id=issue_id)) - conttext = text_t(contnode[0]) - formatted_conttext = nodes.Text(conttext.format(issue=issue)) - formatted_contnode = nodes.inline(conttext, formatted_conttext, - classes=contnode['classes']) - return make_issue_reference(issue, formatted_contnode) - - -def init_transformer(app): - app.add_transform(Issues) - - -def setup(app): - app.require_sphinx('1.0') - app.add_role('issue', IssueRole()) - - app.add_config_value('github_project', None, 'env') - app.add_config_value('github_issue_pattern', - re.compile(r'[Ii]ssue #(\d+)'), 'env') - - app.connect(str('builder-inited'), init_transformer) - app.connect(str('missing-reference'), resolve_issue_reference) |
