diff options
author | Georg Brandl <georg@python.org> | 2012-09-30 13:10:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-09-30 13:10:34 (GMT) |
commit | 7ef90a1a37a17b63cb48c8abd653e0c83455320a (patch) | |
tree | c001f9cfc707227195bf8e053038632e6aa1d26f /Doc/tools | |
parent | 50de85067fd9f4592a4db1454bcd6bba931c8dee (diff) | |
parent | 2cac28b37ef1dfdfc90481cad780c1555c713b04 (diff) | |
download | cpython-7ef90a1a37a17b63cb48c8abd653e0c83455320a.zip cpython-7ef90a1a37a17b63cb48c8abd653e0c83455320a.tar.gz cpython-7ef90a1a37a17b63cb48c8abd653e0c83455320a.tar.bz2 |
merge with 3.3
Diffstat (limited to 'Doc/tools')
-rw-r--r-- | Doc/tools/sphinxext/layout.html | 17 | ||||
-rw-r--r-- | Doc/tools/sphinxext/pyspecific.py | 40 |
2 files changed, 57 insertions, 0 deletions
diff --git a/Doc/tools/sphinxext/layout.html b/Doc/tools/sphinxext/layout.html index db4a386..df728aa 100644 --- a/Doc/tools/sphinxext/layout.html +++ b/Doc/tools/sphinxext/layout.html @@ -8,6 +8,23 @@ {% block extrahead %} <link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" /> {% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %} + {% if pagename == 'whatsnew/news' %} + <script type="text/javascript"> + function dofilter() { + var el = document.getElementById('searchbox'); + var string = el.value.toLowerCase(); + var litags = document.getElementsByTagName('li') + for (var idx = 0; idx < litags.length; idx++) { + var li = litags[idx]; + if (li.innerHTML.toLowerCase().indexOf(string) >= 0) { + li.style.display = ''; + } else { + li.style.display = 'none'; + } + } + } + </script> + {% endif %} {{ super() }} {% endblock %} {% block footer %} diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py index bff10ab..aa6e85f 100644 --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -145,6 +145,45 @@ class DeprecatedRemoved(Directive): return ret +# Support for including Misc/NEWS + +import re +import codecs +from docutils.statemachine import string2lines +from sphinx.util.nodes import nested_parse_with_titles + +issue_re = re.compile('Issue #([0-9]+)') + +class MiscNews(Directive): + has_content = False + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = {} + + def run(self): + fname = self.arguments[0] + source = self.state_machine.input_lines.source( + self.lineno - self.state_machine.input_offset - 1) + source_dir = path.dirname(path.abspath(source)) + try: + fp = codecs.open(path.join(source_dir, fname), encoding='utf-8') + try: + content = fp.read() + finally: + fp.close() + except Exception: + text = 'The NEWS file is not available.' + node = nodes.strong(text, text) + return [node] + content = issue_re.sub(r'`Issue #\1 <http://bugs.python.org/\1>`__', + content) + # remove first 3 lines as they are the main heading + lines = content.splitlines()[3:] + self.state_machine.insert_input(lines, fname) + return [] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -276,3 +315,4 @@ def setup(app): app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) + app.add_directive('miscnews', MiscNews) |