From 94b467dbc89d2057c5435dabc6861b34b219429f Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Sun, 1 Jul 2018 16:10:51 +0200 Subject: [PATCH 01/14] #4255 clarify documentation of ``startdocname`` parameters. * Relative path from source directory * Similar to ``master_doc`` in functionality --- doc/usage/configuration.rst | 58 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index a0fbe641a..98cc4ab8d 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1765,20 +1765,30 @@ information. It must be a list of tuples ``(startdocname, targetname, title, author, documentclass, toctree_only)``, where the items are: - * *startdocname*: document name that is the "root" of the LaTeX file. All - documents referenced by it in TOC trees will be included in the LaTeX file - too. (If you want only one LaTeX file, use your :confval:`master_doc` - here.) - * *targetname*: file name of the LaTeX file in the output directory. - * *title*: LaTeX document title. Can be empty to use the title of the - *startdoc*. This is inserted as LaTeX markup, so special characters like a - backslash or ampersand must be represented by the proper LaTeX commands if - they are to be inserted literally. - * *author*: Author for the LaTeX document. The same LaTeX markup caveat as + *startdocname* + String that specifies the relative path (without file suffix) from the + source directory to the document that is the master document of the LaTeX + file. All documents referenced by the *startdoc* document in TOC trees + will be included in the LaTeX file. (If you want to use the default master + document for your LaTeX build, provide your :confval:`master_doc` here.) + + *targetname* + File name of the LaTeX file in the output directory. + + *title* + LaTeX document title. Can be empty to use the title of the + *startdoc* document. This is inserted as LaTeX markup, so special + characters like a backslash or ampersand must be represented by the proper + LaTeX commands if they are to be inserted literally. + + * *author* + Author for the LaTeX document. The same LaTeX markup caveat as for *title* applies. Use ``\\and`` to separate multiple authors, as in: ``'John \\and Sarah'`` (backslashes must be Python-escaped to reach LaTeX). - * *documentclass*: Normally, one of ``'manual'`` or ``'howto'`` (provided + + *documentclass* + Normally, one of ``'manual'`` or ``'howto'`` (provided by Sphinx and based on ``'report'``, resp. ``'article'``; Japanese documents use ``'jsbook'``, resp. ``'jreport'``.) "howto" (non-Japanese) documents will not get appendices. Also they have a simpler title page. @@ -1786,7 +1796,8 @@ information. the "sphinx" package is always loaded in order to define Sphinx's custom LaTeX commands. - * *toctree_only*: Must be ``True`` or ``False``. If true, the *startdoc* + *toctree_only* + Must be ``True`` or ``False``. If true, the *startdoc* document itself is not included in the output, only the documents referenced by it via TOC trees. With this option, you can put extra stuff in the master document that shows up in the HTML, but not the LaTeX @@ -2227,9 +2238,11 @@ These options influence manual page output. section)``, where the items are: *startdocname* - Document name that is the "root" of the manual page. All documents - referenced by it in TOC trees will be included in the manual file too. - (If you want one master manual page, use your :confval:`master_doc` here.) + String that specifies the relative path (without file suffix) from the + source directory to the document that is the master of the manual page. + All documents referenced by the *startdoc* document in TOC trees will be + included in the manual file. (If you want to use the default master + document for your manual pages build, use your :confval:`master_doc` here.) *name* Name of the manual page. This should be a short string without spaces or @@ -2272,17 +2285,20 @@ These options influence Texinfo output. are: *startdocname* - Document name that is the "root" of the Texinfo file. All documents - referenced by it in TOC trees will be included in the Texinfo file too. - (If you want only one Texinfo file, use your :confval:`master_doc` here.) + String that specifies the relative path (without file suffix) from the + source directory to the document that is the master document of the Texinfo + file. All documents referenced by the *startdoc* document in TOC trees + will be included in the Texinfo file. (If you want to use the default + master document for your Texinfo build, provide your :confval:`master_doc` + here.) *targetname* File name (no extension) of the Texinfo file in the output directory. *title* - Texinfo document title. Can be empty to use the title of the *startdoc*. - Inserted as Texinfo markup, so special characters like ``@`` and ``{}`` - will need to be escaped to be inserted literally. + Texinfo document title. Can be empty to use the title of the *startdoc* + document. Inserted as Texinfo markup, so special characters like ``@`` and + ``{}`` will need to be escaped to be inserted literally. *author* Author for the Texinfo document. Inserted as Texinfo markup. Use ``@*`` From c126067f4ea1c70d37f4e04979c4afa9f508058b Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Mon, 16 Jul 2018 23:17:44 +0200 Subject: [PATCH 02/14] #4886 add tests to better cover the current link check ignore configuration behavior --- tests/roots/test-linkcheck/links.txt | 2 ++ tests/test_build_linkcheck.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/roots/test-linkcheck/links.txt b/tests/roots/test-linkcheck/links.txt index 36376bef4..d5057e08e 100644 --- a/tests/roots/test-linkcheck/links.txt +++ b/tests/roots/test-linkcheck/links.txt @@ -9,3 +9,5 @@ Some additional anchors to exercise ignore code * `Example Bar invalid `_ * `Example Bar invalid `_ tests that default ignore anchor of #! does not need to be prefixed with / * `Example Bar invalid `_ +* `Example anchor invalid `_ +* `Complete nonsense `_ diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 839a15628..560eb2499 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -21,14 +21,21 @@ def test_defaults(app, status, warning): content = (app.outdir / 'output.txt').text() print(content) - # looking for #top should fail + # looking for '#top' and 'does-not-exist' not found should fail assert "Anchor 'top' not found" in content - assert len(content.splitlines()) == 1 + assert "Anchor 'does-not-exist' not found" in content + # looking for non-existent URL should fail + assert " Max retries exceeded with url: /doesnotexist" in content + assert len(content.splitlines()) == 3 @pytest.mark.sphinx( 'linkcheck', testroot='linkcheck', freshenv=True, - confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]}) + confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"], + 'linkcheck_ignore': [ + 'https://localhost:7777/doesnotexist', + 'http://www.sphinx-doc.org/en/1.7/intro.html#*'] + }) def test_anchors_ignored(app, status, warning): app.builder.build_all() From 537a69e5180f3380490592204022ff30f4a7556e Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Mon, 16 Jul 2018 23:22:26 +0200 Subject: [PATCH 03/14] #4886 adjust documentation to match actual link check behavior --- doc/usage/configuration.rst | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 8db606515..288290a27 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -2485,12 +2485,20 @@ Options for the linkcheck builder .. confval:: linkcheck_anchors_ignore - A list of regular expressions that match URIs that should skip checking - the validity of anchors in links. This allows skipping entire sites, where - anchors are used to control dynamic pages, or just specific anchors within - a page, where JavaScript is used to add anchors dynamically, or use the - fragment as part of to trigger an internal REST request. Default is - ``["/#!"]``. + A list of regular expressions that match anchors Sphinx should skip when + checking the validity of anchors in links. This allows skipping anchors that + a website's JavaScript adds to control dynamic pages or when triggering an + internal REST request. Default is ``["^!"]``. + + .. note:: + + If you want to ignore anchors of a specific page or of pages that match a + specific pattern, use :confval:`linkcheck_ignore` instead, for example as + follows:: + + linkcheck_ignore = [ + 'http://www.sphinx-doc.org/en/1.7/intro.html#*' + ] .. versionadded:: 1.5 From f605012617d4e1005cab02393fb0cf4ea9cd435f Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Tue, 17 Jul 2018 20:40:49 +0200 Subject: [PATCH 04/14] #4886 remove obsolete `*` --- doc/usage/configuration.rst | 2 +- tests/test_build_linkcheck.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 288290a27..288b95ae4 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -2497,7 +2497,7 @@ Options for the linkcheck builder follows:: linkcheck_ignore = [ - 'http://www.sphinx-doc.org/en/1.7/intro.html#*' + 'http://www.sphinx-doc.org/en/1.7/intro.html#' ] .. versionadded:: 1.5 diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 560eb2499..1716a0c42 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -34,7 +34,7 @@ def test_defaults(app, status, warning): confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"], 'linkcheck_ignore': [ 'https://localhost:7777/doesnotexist', - 'http://www.sphinx-doc.org/en/1.7/intro.html#*'] + 'http://www.sphinx-doc.org/en/1.7/intro.html#'] }) def test_anchors_ignored(app, status, warning): app.builder.build_all() From 8066d36e3cba5eabc09ed95dc2f9055d4badc2ca Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Wed, 18 Jul 2018 19:40:22 +0200 Subject: [PATCH 05/14] #4886 clarify example/note --- doc/usage/configuration.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 288b95ae4..22d0966b4 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -2493,8 +2493,9 @@ Options for the linkcheck builder .. note:: If you want to ignore anchors of a specific page or of pages that match a - specific pattern, use :confval:`linkcheck_ignore` instead, for example as - follows:: + specific pattern (but still check occurrences of the same page(s) that + don't have anchors), use :confval:`linkcheck_ignore` instead, for example + as follows:: linkcheck_ignore = [ 'http://www.sphinx-doc.org/en/1.7/intro.html#' From 395d60d49e982a5113afb0ab0118ae1250d9c23a Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Thu, 19 Jul 2018 21:10:16 +0200 Subject: [PATCH 06/14] #4255 improve conciseness --- doc/usage/configuration.rst | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 98cc4ab8d..b4d4a4f84 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1766,9 +1766,8 @@ information. documentclass, toctree_only)``, where the items are: *startdocname* - String that specifies the relative path (without file suffix) from the - source directory to the document that is the master document of the LaTeX - file. All documents referenced by the *startdoc* document in TOC trees + String that specifies the :term:`document name` of the LaTeX file's master + document. All documents referenced by the *startdoc* document in TOC trees will be included in the LaTeX file. (If you want to use the default master document for your LaTeX build, provide your :confval:`master_doc` here.) @@ -1776,32 +1775,29 @@ information. File name of the LaTeX file in the output directory. *title* - LaTeX document title. Can be empty to use the title of the - *startdoc* document. This is inserted as LaTeX markup, so special - characters like a backslash or ampersand must be represented by the proper - LaTeX commands if they are to be inserted literally. + LaTeX document title. Can be empty to use the title of the *startdoc* + document. This is inserted as LaTeX markup, so special characters like a + backslash or ampersand must be represented by the proper LaTeX commands if + they are to be inserted literally. - * *author* - Author for the LaTeX document. The same LaTeX markup caveat as - for *title* applies. Use ``\\and`` to separate multiple authors, as in: - ``'John \\and Sarah'`` (backslashes must be Python-escaped to reach - LaTeX). + *author* + Author for the LaTeX document. The same LaTeX markup caveat as for *title* + applies. Use ``\\and`` to separate multiple authors, as in: + ``'John \\and Sarah'`` (backslashes must be Python-escaped to reach LaTeX). *documentclass* - Normally, one of ``'manual'`` or ``'howto'`` (provided - by Sphinx and based on ``'report'``, resp. ``'article'``; Japanese - documents use ``'jsbook'``, resp. ``'jreport'``.) "howto" (non-Japanese) - documents will not get appendices. Also they have a simpler title page. - Other document classes can be given. Independently of the document class, - the "sphinx" package is always loaded in order to define Sphinx's custom - LaTeX commands. + Normally, one of ``'manual'`` or ``'howto'`` (provided by Sphinx and based + on ``'report'``, resp. ``'article'``; Japanese documents use ``'jsbook'``, + resp. ``'jreport'``.) "howto" (non-Japanese) documents will not get + appendices. Also they have a simpler title page. Other document classes + can be given. Independently of the document class, the "sphinx" package is + always loaded in order to define Sphinx's custom LaTeX commands. *toctree_only* - Must be ``True`` or ``False``. If true, the *startdoc* - document itself is not included in the output, only the documents - referenced by it via TOC trees. With this option, you can put extra stuff - in the master document that shows up in the HTML, but not the LaTeX - output. + Must be ``True`` or ``False``. If true, the *startdoc* document itself is + not included in the output, only the documents referenced by it via TOC + trees. With this option, you can put extra stuff in the master document + that shows up in the HTML, but not the LaTeX output. .. versionadded:: 1.2 In the past including your own document class required you to prepend the @@ -2238,11 +2234,11 @@ These options influence manual page output. section)``, where the items are: *startdocname* - String that specifies the relative path (without file suffix) from the - source directory to the document that is the master of the manual page. - All documents referenced by the *startdoc* document in TOC trees will be - included in the manual file. (If you want to use the default master - document for your manual pages build, use your :confval:`master_doc` here.) + String that specifies the :term:`document name` of the manual page's master + document. All documents referenced by the *startdoc* document in TOC trees + will be included in the manual file. (If you want to use the default + master document for your manual pages build, use your :confval:`master_doc` + here.) *name* Name of the manual page. This should be a short string without spaces or @@ -2285,12 +2281,11 @@ These options influence Texinfo output. are: *startdocname* - String that specifies the relative path (without file suffix) from the - source directory to the document that is the master document of the Texinfo - file. All documents referenced by the *startdoc* document in TOC trees - will be included in the Texinfo file. (If you want to use the default - master document for your Texinfo build, provide your :confval:`master_doc` - here.) + String that specifies the :term:`document name` of the the Texinfo file's + master document. All documents referenced by the *startdoc* document in + TOC trees will be included in the Texinfo file. (If you want to use the + default master document for your Texinfo build, provide your + :confval:`master_doc` here.) *targetname* File name (no extension) of the Texinfo file in the output directory. From c0ba51902f943c6f5cae56429fb0c73652ce1d21 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 21 Jul 2018 14:35:31 +0900 Subject: [PATCH 07/14] Fix #5198: document not in toctree warning when including files only for parallel builds --- CHANGES | 3 +++ sphinx/environment/__init__.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index f0133ff94..778df02e0 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,9 @@ Features added Bugs fixed ---------- +* #5198: document not in toctree warning when including files only for parallel + builds + Testing -------- diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 86d69cc3a..4d3935faf 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -310,6 +310,7 @@ class BuildEnvironment(object): if docname in self.all_docs: self.all_docs.pop(docname, None) self.reread_always.discard(docname) + self.included.discard(docname) for version, changes in self.versionchanges.items(): new = [change for change in changes if change[1] != docname] @@ -330,6 +331,8 @@ class BuildEnvironment(object): self.all_docs[docname] = other.all_docs[docname] if docname in other.reread_always: self.reread_always.add(docname) + if docname in other.included: + self.included.add(docname) for version, changes in other.versionchanges.items(): self.versionchanges.setdefault(version, []).extend( From fe3d4ddc20828207ea6b1d0cdc387108a167d3c9 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 22 Jul 2018 00:03:17 +0900 Subject: [PATCH 08/14] Fix classic theme: collapsiblesidebar is always enabled --- sphinx/themes/classic/layout.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/themes/classic/layout.html b/sphinx/themes/classic/layout.html index 8042e3f7e..bee2ffd1e 100644 --- a/sphinx/themes/classic/layout.html +++ b/sphinx/themes/classic/layout.html @@ -9,9 +9,9 @@ #} {%- extends "basic/layout.html" %} -{% if theme_collapsiblesidebar|tobool %} {%- block scripts %} {{ super() }} + {% if theme_collapsiblesidebar|tobool %} + {% endif %} {%- endblock %} -{% endif %} From d0900001afab78dc9d8cb2356e82be8eae161863 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 22 Jul 2018 00:09:11 +0900 Subject: [PATCH 09/14] doc: collapsiblesidebar works well with stickysidebar --- doc/theming.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/theming.rst b/doc/theming.rst index fccc2362e..3308fe632 100644 --- a/doc/theming.rst +++ b/doc/theming.rst @@ -150,7 +150,7 @@ These themes are: - **collapsiblesidebar** (true or false): Add an *experimental* JavaScript snippet that makes the sidebar collapsible via a button on its side. - *Doesn't work with "stickysidebar".* Defaults to ``False``. + Defaults to ``False``. - **externalrefs** (true or false): Display external links differently from internal links. Defaults to ``False``. From 8c29801f271eb7c258924fef02609d1b8d9d1d25 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 22 Jul 2018 01:06:17 +0900 Subject: [PATCH 10/14] Close #2820: autoclass directive supports nested class --- CHANGES | 1 + sphinx/ext/autodoc/importer.py | 17 +++++++++++++++-- tests/test_autodoc.py | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index e57a0dad6..114c34cf5 100644 --- a/CHANGES +++ b/CHANGES @@ -162,6 +162,7 @@ Features added if :confval:`latex_engine` is ``'xelatex'`` or ``'lualatex'``. * #4976: ``SphinxLoggerAdapter.info()`` now supports ``location`` parameter * #5122: setuptools: support nitpicky option +* #2820: autoclass directive supports nested class Bugs fixed ---------- diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 20d448506..4b92a7b59 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -167,8 +167,21 @@ def import_object(modname, objpath, objtype='', attrgetter=safe_getattr, warning logger.debug('[autodoc] import %s', modname) try: - module = import_module(modname, warningiserror=warningiserror) - logger.debug('[autodoc] => %r', module) + module = None + objpath = list(objpath) + while module is None: + try: + module = import_module(modname, warningiserror=warningiserror) + logger.debug('[autodoc] import %s => %r', modname, module) + except ImportError: + logger.debug('[autodoc] import %s => failed', modname) + if '.' in modname: + # retry with parent module + modname, name = modname.rsplit('.', 1) + objpath.insert(0, name) + else: + raise + obj = module parent = None object_name = None diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 53d8a1e14..a42210a4c 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -771,6 +771,9 @@ def test_generate(): ('class', 'target.Outer.Inner'), ('method', 'target.Outer.Inner.meth')], 'class', 'Outer', all_members=True) + assert_processes([('class', 'target.Outer.Inner'), + ('method', 'target.Outer.Inner.meth')], + 'class', 'target.Outer.Inner', all_members=True) # test descriptor docstrings assert_result_contains(' Descriptor instance docstring.', From cfc56329d4453c37bc3d0b8e7ea8813c10e1a7c6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 22 Jul 2018 01:50:09 +0900 Subject: [PATCH 11/14] Fix #344: autosummary does not understand docstring of module level attributes --- CHANGES | 1 + sphinx/ext/autodoc/__init__.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index e57a0dad6..92475536c 100644 --- a/CHANGES +++ b/CHANGES @@ -174,6 +174,7 @@ Bugs fixed * #5132: (lualatex) PDF build fails if indexed word starts with Unicode character * #5133: latex: index headings "Symbols" and "Numbers" not internationalized * #5114: sphinx-build: Handle errors on scanning documents +* #344: autosummary does not understand docstring of module level attributes Testing -------- diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 62143fda4..4a9b59537 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1265,6 +1265,11 @@ class DataDocumenter(ModuleLevelDocumenter): # type: (bool) -> None pass + def get_real_modname(self): + # type: () -> str + return self.get_attr(self.parent or self.object, '__module__', None) \ + or self.modname + class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: ignore """ From 732ebb5d1e5a2114870525a8a789ec39df19bcfb Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 21 Jul 2018 23:13:16 +0200 Subject: [PATCH 12/14] Capitalization: "Table Of Contents" -> "Table of Contents". This is consistent with "Complete Table of Contents" (which is already in the database), as well as e.g. "Indices and Tables" where "and" is not capitalized. This is also fairly standard title-case practice. --- sphinx/themes/agogo/layout.html | 2 +- sphinx/themes/basic/globaltoc.html | 2 +- sphinx/themes/basic/localtoc.html | 2 +- sphinx/themes/haiku/layout.html | 2 +- sphinx/themes/scrolls/layout.html | 2 +- tests/test_theming.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sphinx/themes/agogo/layout.html b/sphinx/themes/agogo/layout.html index 8bd476cad..f2c880537 100644 --- a/sphinx/themes/agogo/layout.html +++ b/sphinx/themes/agogo/layout.html @@ -43,7 +43,7 @@