Commit Graph

3809 Commits

Author SHA1 Message Date
Takeshi KOMIYA
f803266d63
Merge pull request #8805 from tk0miya/8775_workaround
Fix #8775: Avoid the crash of autodoc caused by type union operator
2021-02-01 21:35:04 +09:00
Takeshi KOMIYA
223f59b3c5
Merge pull request #8802 from tk0miya/8775_pydomain_pep604
py domain: Support type union operator (PEP-604) (refs: #8775)
2021-02-01 21:22:38 +09:00
Takeshi KOMIYA
7ca5248057 Fix #8775: Avoid the crash of autodoc caused by type union operator
The type union operator (PEP-604) causes autodoc crashed in python 3.9
or below because of the syntax is not suppoerted yet in the interpreters.
Internally, `typing.get_type_hints()` raises TypeError on evaluating the
annotation by BitOr operator for types.

To avoid the crash, this adds a fallback not to evaluate the annotations
and keep as is.  As a side effect, `autodoc_type_aliases` will not work
for the modules and classes that uses type union operator for their
annotations.
2021-02-01 21:21:56 +09:00
Takeshi KOMIYA
2956f19674
Merge pull request #8803 from tk0miya/8775_autodoc_type_union_operator
autodoc: Support type union operator (PEP-604) (refs: #8775)
2021-02-01 21:19:45 +09:00
Takeshi KOMIYA
2c2b8c1154 py domain: Support type union operator (PEP-604) (refs: #8775)
Upgrade annotation parser for python domain to support type union
operator introduced in PEP-604.  It's available on all python
interpreters.
2021-02-01 21:12:29 +09:00
Takeshi KOMIYA
6d8c9183fa Fix #8800: autodoc: Uninitialized attributes in superclass are recognized as undocumented
Unintentionally, uninitialized attributes defined at superclasses are
recognized as undocumented in the filtering step.  Therefore, they are
filtered if `:undoc-members:` option given.
2021-02-01 21:06:07 +09:00
pbudzyns
fd6587d5e9 rebase and fix tests 2021-02-01 10:58:09 +01:00
pbudzyns
270921d73a Merge remote-tracking branch 'upstream/3.x' into exclude-members-fix 2021-02-01 10:46:44 +01:00
pbudzyns
8d380cadc7 check if autodoc_defaults are str, fix tests 2021-02-01 09:46:19 +01:00
Takeshi KOMIYA
af6ed52ca1
Merge branch '3.x' into 8446_escape_spaces_inside_desc_signatures 2021-02-01 01:24:02 +09:00
Takeshi KOMIYA
7318d1dfd4 autodoc: Support type union operator (PEP-604) (refs: #8775)
Upgrade autodoc to support type union operator introduced in
PEP-604. It's available only with python 3.10+.
2021-01-31 23:38:36 +09:00
jfbu
e77378da1c Merge branch '3.x' 2021-01-30 21:18:00 +01:00
jfbu
5b6a273825 Let latex writer line trimming from depart_entry() work as before #8781
This is cosmetic as the blank line starting varwidth environment used
for merged table cells in latex output changed nothing to PDF.

Nevertheless I extended a unit test to have a multi-paragraph merged
cell using varwidth. What is important is that \sphinxAtStartPar line
itself is never followed by blank line.
2021-01-30 10:26:42 +01:00
Takeshi KOMIYA
339ce2f894 Merge branch '3.x' 2021-01-30 11:49:08 +09:00
Jean-François B
879bf54a05
Merge pull request #8781 from jfbu/latex_hyphenation_of_first_word
Fix #8780: long words in narrow columns may not be hyphenated
2021-01-29 20:57:54 +01:00
jfbu
d6e11b89e9 Fix suppression of needed whiteline, encapsulate into \sphinxAtStartPar
Define it to do nothing with lualatex engine
2021-01-29 10:40:50 +01:00
jfbu
185a2d27fe Fix #8780: long words in narrow columns may not be hyphenated
This is done by adding '\hskip0pt\relax\n' whenever a paragraph starts.
2021-01-29 00:24:44 +01:00
Takeshi KOMIYA
57126d9ee2
Merge pull request #8773 from francoisfreitag/app-build
Linkcheck: Use app.build() to trigger the test build
2021-01-28 23:28:31 +09:00
François Freitag
c7eb7cd127
Linkcheck: Use app.build() to trigger the test build
Instead of using application members to access the builder and trigger a
build, use the main app interface.
It ensures the builder setup is realistic, builder cleanups are executed
and the build-finished events are emitted.
2021-01-27 18:55:36 +01:00
Takeshi KOMIYA
c9480f9943 Merge branch '3.x' 2021-01-28 00:56:46 +09:00
Takeshi KOMIYA
241577f65e Merge branch '8137_urldecode' into 3.x 2021-01-26 02:11:13 +09:00
Takeshi KOMIYA
84dc65ad51 html: html_codeblock_linenos_style defaults to 'inline' (refs: #7849)
As discussed in #7879, the default style of line numbers for code
blocks in HTML output becames 'inline' by default.  And 'table' style
is now deprecated and will be removed in Sphinx-6.0.
2021-01-26 01:42:17 +09:00
pbudzyns
ac5079ed85 redundant '+' has no effect 2021-01-25 16:07:18 +01:00
pbudzyns
381e30c23b add more extendable options and tests 2021-01-25 13:24:01 +01:00
pbudzyns
7348ba8d60 add more extendable options and tests 2021-01-25 13:15:13 +01:00
pbudzyns
0a85b4148e add more extendable options and tests 2021-01-25 12:54:08 +01:00
Takeshi KOMIYA
8203642c41
Merge pull request #8752 from tk0miya/1638_permalinks_for_glossary_terms
Close #1638: html: Add permalink icons to glossary terms
2021-01-25 20:35:44 +09:00
Takeshi KOMIYA
16a8a17779
Merge pull request #8747 from tk0miya/8134_args_for_mock_decorator
Fix #8134: autodoc: crashes when mocked decorator takes arguments
2021-01-25 20:33:40 +09:00
Takeshi KOMIYA
949ec8737f Close #1638: html: Add permalink icons to glossary terms 2021-01-24 23:35:37 +09:00
Takeshi KOMIYA
502c4ee5fb Merge branch '3.x' 2021-01-24 14:32:13 +09:00
Takeshi KOMIYA
a78c6b799f Fix #8134: autodoc: crashes when mocked decorator takes arguments
autodoc crashed when a decorator in mocked module takes arguments
because mock system returns the first argument for the decorator as a
decorated object.

This changes the approach for mocking decorators that remembers
arguments for each decoration, and fetch the latest argument on
generating document.
2021-01-24 14:18:00 +09:00
Takeshi KOMIYA
15cbc6dbb0 Close #6550: html: Allow to use HTML permalink texts
Add new configuration variables: `html_permalinks` and
`html_permalinks_icon`.

This refines the settings around HTML permalinks.

* html_add_permalinks
  * Deprecated.
* html_permalinks
  * Enable or disable permalinks feature.
* html_permalinks_icon
  * Change the icon for permalinks
2021-01-24 14:17:07 +09:00
Takeshi KOMIYA
97f54bdf31
Merge pull request #8733 from tk0miya/update_underscore.js-1.12.0
Update Underscore.js to 1.12.0
2021-01-24 14:07:16 +09:00
Takeshi KOMIYA
deda1918fc
Merge pull request #8731 from tk0miya/8004_preprocess_types_for_google
Fix #8004: napoleon_preprocess_types for Google style docstrings
2021-01-24 13:59:21 +09:00
Takeshi KOMIYA
2522b61185
Merge pull request #8729 from tk0miya/8727_namespace_subpackage
Fix #8727: apidoc: namespace module file is not generated if no submodules
2021-01-24 13:58:33 +09:00
jfbu
2e22bd0a23 Merge branch 'master' into latex_font_for_pdflatex 2021-01-23 09:13:08 +01:00
Takeshi KOMIYA
af0dfa20d0
Merge pull request #8247 from silene/inter_prodlist_refs
Allow production lists to refer to tokens from other production groups.
2021-01-23 17:07:52 +09:00
Guillaume Melquiond
ffacb2ca18 Add testcase. 2021-01-23 08:57:36 +01:00
Takeshi KOMIYA
1b4265da4d Update Underscore.js to 1.12.0 2021-01-23 16:41:59 +09:00
Takeshi KOMIYA
440e64a91b Fix #8004: napoleon_preprocess_types for Google style docstrings
Type definitions in Google style docstrings are rendered as references
when :confval:`napoleon_preprocess_types` enabled.
2021-01-23 14:20:19 +09:00
Takeshi KOMIYA
650f8ea237 Fix #8727: apidoc: namespace module file is not generated if no submodules
sphinx-apidoc should generate a namespace module file when
`--implicit-namespace` option given.  This fixes the case the namespace
module has subpackages, but no submodules.
2021-01-23 00:40:16 +09:00
Takeshi KOMIYA
5ce72f465b Merge branch '3.x' 2021-01-22 22:52:32 +09:00
Takeshi KOMIYA
a71028bf9e
Merge pull request #8719 from tk0miya/8714_kbd_capslock
Fix #8714: html: kbd role with "Caps Lock" rendered incorrectly
2021-01-22 22:07:06 +09:00
Takeshi KOMIYA
d6f41227d7 Fix #8714: html: kbd role with "Caps Lock" rendered incorrectly
`:kbd:` role has to support keys in consist of multiple words (ex. caps
lock, num lock, etc.)
2021-01-22 21:58:19 +09:00
Takeshi KOMIYA
5260143afe Fix #8704: viewcode: anchors are generated in incremental build
The anchors for viewcode was generated in the reading phase only if
supported builder is used.  It causes anchors are missing on the
incremental build after the build for non supported builder.

This introduces `viewcode_anchor` node to insert the anchor even if non
supported builders.  They will be converted to the anchor tag in the
resolving phase for supported builders.  Or, they will be removed for
non supported builders.
2021-01-22 21:41:42 +09:00
Takeshi KOMIYA
d5d072bc3a Merge branch '3.4.x' into 3.x 2021-01-22 21:40:27 +09:00
Takeshi KOMIYA
b2bb12ad91 Fix #8720: viewcode: module pages are generated for epub on incremental build
The module pages should be generated for epub only if enabled via
configuration.  But they are generated after the build for other
viewcode-supported builders.  This checks the current builder on
generating module pages.
2021-01-22 00:51:21 +09:00
jfbu
99a8b7f37f LaTeX: update default font configuration
This replaces times package with tgtermes and tgheros (clones of Times and
Helvetica with better LaTeX support) and the monospace font from txfonts
package (txtt). This font is better matched with Times-like fonts than
Courier clones.

The changes applies to pdflatex/platex/uplatex.

Fixes: #8711
2021-01-20 23:03:08 +01:00
Takeshi KOMIYA
73db152cf6 Close #5560: napoleon_use_param also affect "other parameters" section 2021-01-20 23:21:11 +09:00
Takeshi KOMIYA
cead0f6ddf linkcheck: Fix race condition that could lead to checking the availability of the same URL twice
So far, linkcheck scans all of references and images from documents, and
checks them parallel.  As a result, some URL would be checked twice (or
more) by race condition.

This collects the URL via post-transforms, and removes duplicated URLs
before checking availability.

refs: #4303
2021-01-20 20:58:27 +09:00
Takeshi KOMIYA
ca0677086d
Merge pull request #8658 from SolidifiedRay/feature-custom-section
Close #8573: napoleon: Add more custom section styles
2021-01-19 21:13:13 +09:00
SolidifiedRay
7ad85cd1e0 Close #8573: napoleon: Add more custom section styles 2021-01-18 11:43:40 -08:00
Takeshi KOMIYA
bc56384fb9 Fix #1112: download role creates duplicated copies
`:download:` role creates duplicated copies when the document contains
two or more the role for the same file, but in different form.  It
considers two paths are different when one contains relative path like
`path/to/../file.dat`.

Internally, `env.relfn2path()` does not normalize the given path in
relative form.  As a result, download role can't detect the same paths
are given.  This adds `os.path.normpath()` to `env.relfn2path()` to
normalize the path.
2021-01-19 02:27:20 +09:00
Takeshi KOMIYA
9ced1e355a refactor: test: Do not use deprecated function: execfile_() 2021-01-17 18:39:27 +09:00
Takeshi KOMIYA
d88166e84b Close #8514: autodoc: Default values of overloads are taken from actual implementation
As a well-known idiom, mypy recommends to use ellipsis ("...") for
default argument values as a elided style.  This allows to write the
style and helps to document it with copying the default argument
values from actual implementation.

Note: This does not copy the default argument value when the argument
of overloaded function has its own default value.
2021-01-17 02:32:50 +09:00
Takeshi KOMIYA
425cd1af02 Fix #8693: autodoc: Default values for overloads are rendered as string
The default values for overloaded functions are rendered as string
literal unexpectedly because autodoc extracts code snippets from
the source code, not actual value (ex. int, ellipsis, and so on).

This introduces a simple wrapper class; `DefaultValue` to render these
code snippets like actual values, not string literals.
2021-01-17 02:30:20 +09:00
Takeshi KOMIYA
30f8640bab Merge branch '3.x' 2021-01-16 21:51:46 +09:00
Takeshi KOMIYA
d635d94eeb
Merge pull request #8685 from tk0miya/8683_strftime_z
Fix #8683: html_last_updated_fmt does not support UTC offset (%z)
2021-01-14 01:11:24 +09:00
Takeshi KOMIYA
b742bde8e6
Merge pull request #8684 from tk0miya/2030_automatic_dedent
Fix #2030: automatic dedent support in code-block directive
2021-01-14 01:11:02 +09:00
Takeshi KOMIYA
fddc42847f Fix #2030: automatic dedent support in code-block directive 2021-01-13 01:10:28 +09:00
Takeshi KOMIYA
233e359330
Merge pull request #8679 from tk0miya/8651_xref_for_rubric
Fix #8651: cross-reference for a rubric having inline item is broken
2021-01-13 01:01:36 +09:00
Takeshi KOMIYA
8ff8b5532c Fix #8683: html_last_updated_fmt generates wrong time zone for %Z
sphinx.util.i18n:format_date() converts '%Z' to full name of time zone
unexpectedly.  It should be converted to short name.
2021-01-13 00:50:01 +09:00
Takeshi KOMIYA
d5559e1ba2 Fix #8683: html_last_updated_fmt does not support UTC offset (%z)
sphinx.util.i18n:format_date() does not support %z so far.  This
adds a mapping for %z to the babel form 'ZZZ'.
2021-01-13 00:49:59 +09:00
Jakob Lykke Andersen
f7a1d66359 C++, fix object types for xrefs
Make them all work with intersphinx.
Strengthen templateParam a bit.
2021-01-11 20:51:36 +01:00
Jakob Lykke Andersen
750e6ec431 C, fix object types for xrefs
Add 'identifer' to all and 'type' to types.

Fixes sphinx-doc/sphinx#8341
2021-01-11 20:51:36 +01:00
Takeshi KOMIYA
12ec8f0cae Fix #8651: cross-reference for a rubric having inline item is broken
The implementation of the standard domain so far has considered the
first child of the rubric node is the title of the rubric.  But it can
may multiple nodes when the rubric title is marked up.

This extracts the title of the rubric from the whole of the children
of it.
2021-01-11 22:50:45 +09:00
Takeshi KOMIYA
b372a99c01
Merge pull request #8674 from tk0miya/207_multiple_highlight_options
Close #207: Now highlight_language supports multiple languages
2021-01-11 21:49:29 +09:00
Takeshi KOMIYA
32ac5f2e57 Close #207: Now highlight_language supports multiple languages
This changes the structure of `highlight_options` to a dictionary that
maps language names to option dictionary.  It allows to setting pygments
options for multiple languages at once.
2021-01-11 21:40:09 +09:00
Takeshi KOMIYA
a3df1d00c7 test: Add testcase for relative/short xref for py domain 2021-01-11 03:12:39 +09:00
Jakob Lykke Andersen
8a11f909a7 C, fix namespace lookup for expr role 2021-01-10 12:35:28 +01:00
Takeshi KOMIYA
5460ea103b Merge branch '3.x' 2021-01-08 01:23:17 +09:00
Takeshi KOMIYA
af4e615a8a Close #6241: html: Allow to add JS/CSS files to the specific page
Allow to add JS/CSS files to the specific page when an extension calls
`app.add_js_file()` or `app.add_css_file()` on `html-page-context`
event.
2021-01-07 02:12:07 +09:00
Takeshi KOMIYA
5ba5602d71
Merge pull request #8638 from tk0miya/5977_dont_link_var_field
Close #5977: :var: field do not create a cross-reference …
2021-01-06 01:00:12 +09:00
Takeshi KOMIYA
5b392e3951 refactor: Move CSS tags in basic/layout.html to `css_files` variable
To make CSS customizable, all CSS files in basic/layout.html has their
priority: 200.  Therefore, extensions and users can insert their own
custom CSS files before or just after them.

As a side effect, the CSS tags in basic/layout.html are removed.  These
CSS files will be rendered via `css_files` template variable.

refs: #8634, c5f0398010
2021-01-03 02:41:17 +09:00
Takeshi KOMIYA
a9c7dd7037 Merge branch '3.x' 2021-01-03 00:20:27 +09:00
Takeshi KOMIYA
e9a4ebf70d doc: Add explanation for the priority attribute of html_*_files 2021-01-03 00:16:10 +09:00
Takeshi KOMIYA
c5f0398010 Close #8634: html: Allow to change the order of JS/CSS
`Sphinx.add_js_file()` and `Sphinx.add_css_file()` take `priority`
argument to change the order of JS/CSS files.
2021-01-02 02:06:34 +09:00
Takeshi KOMIYA
918086b559 Close #5977: :var: field do not create a cross-reference
Since its beginning, `:var:` field has created a cross-reference to the
attribute having the same name.  It is meaningful only if the attribute
is documented by `py:attribute` directive.  It means the `:var:` field
and `:attr:` role are almost the same and conflicted.  Additionally,
the cross-reference points incorrect variable if the target is not
documented.

Thus, the cross-reference feature of `:var:` field is disabled.
2021-01-01 22:53:23 +09:00
Takeshi KOMIYA
9cac2001f7 test: py domain: Add a testcase for :var: field 2021-01-01 18:15:42 +09:00
Takeshi KOMIYA
4b452338f9 Merge branch '3.x' 2021-01-01 13:57:19 +09:00
Takeshi KOMIYA
7ecf6b88aa Merge branch '3.4.x' into 3.x 2021-01-01 13:56:19 +09:00
Takeshi KOMIYA
1544097af5 Merge branch '3.x' 2021-01-01 13:55:12 +09:00
Takeshi KOMIYA
f996859420 A happy new year!
.. note::

   $ find sphinx tests LICENSE doc/conf.py -type f -exec sed -i '' -e 's/2007\-20../2007-2021/' {} \;
   $ git co sphinx/locale/**/*.js sphinx/templates/epub3/mimetype
2021-01-01 13:40:48 +09:00
Takeshi KOMIYA
b2c9297bd2
Merge pull request #8627 from tk0miya/8315_struct.Struct
Fix #8315: autodoc: Failed to resolve struct.Struct type annotation
2021-01-01 13:13:11 +09:00
Takeshi KOMIYA
663074e3ce
Merge pull request #8626 from tk0miya/refactor_test_autosummary
refactor: test: Use rollback_sysmodules fixture in test_ext_autosummary
2021-01-01 13:12:35 +09:00
Takeshi KOMIYA
05b67f2a3e
Merge pull request #8633 from tk0miya/merge_3.4.x
Merge 3.4.x to 3.x
2021-01-01 13:11:56 +09:00
Takeshi KOMIYA
9ec65ff039 Merge branch '3.4.x' into merge_3.4.x 2020-12-31 21:33:43 +09:00
Takeshi KOMIYA
2eb8927b89 Fix test: missing compound class for kbd tag 2020-12-31 21:20:38 +09:00
Takeshi KOMIYA
b31b8df9bf
Merge pull request #8620 from tk0miya/8619_compound_kbd
Close #8619: html: kbd role generates customizable HTML tags for compound keys
2020-12-31 21:11:42 +09:00
Takeshi KOMIYA
62a0ee3fef Merge branch '3.x' 2020-12-31 14:33:09 +09:00
Takeshi KOMIYA
f1a051fdfc Fix #8315: autodoc: Failed to resolve struct.Struct type annotation
The builtin module, ``struct.Struct`` does not have correct module
name since Python 3.8.  This allows to refer it automatically.
2020-12-31 14:25:05 +09:00
Takeshi KOMIYA
54e8b8d9bc refactor: test: Use rollback_sysmodules fixture in test_ext_autosummary 2020-12-31 10:55:45 +09:00
Takeshi KOMIYA
e3b1fdeeeb
Merge branch '3.4.x' into 8602_process-docstring_for_nondatadescriptors 2020-12-31 10:13:03 +09:00
Takeshi KOMIYA
6a53c53d53 Fix #8618: html: incorrect HTML for single compound-kdb separators 2020-12-30 21:12:00 +09:00
Takeshi KOMIYA
8e5f4e5616 Close #8619: html: kbd role generates customizable HTML tags for compound keys 2020-12-30 20:36:09 +09:00
Takeshi KOMIYA
a122397b4b Merge branch '3.x' 2020-12-29 18:37:45 +09:00
Takeshi KOMIYA
3f7bf48715 Merge branch '3.4.x' into 3.x 2020-12-29 18:33:36 +09:00
Takeshi KOMIYA
97f36a2d02 Fix #8602: autodoc: The `autodoc-process-docstring` event is emitted to the non-datadescriptors unexpectedly 2020-12-29 18:04:24 +09:00
Takeshi KOMIYA
85567748d9 Fix #8164: autodoc: Classes that inherit mocked class are not documented
Use ismock() to check a module member is a mocked or not. It allows not
to skip subclasses of mocked class.
2020-12-29 00:26:23 +09:00
Takeshi KOMIYA
476169284d autodoc: Add a helper that checks the object is mocked; ismock() 2020-12-28 21:50:36 +09:00
Takeshi KOMIYA
05518851d3
Merge branch '3.x' into 8306_autosummary_mocks_are_documented 2020-12-28 17:25:09 +09:00
Takeshi KOMIYA
0d84818739 Fix #8594: autodoc: empty __all__ attribute is ignored
An empty `__all__` should be represented as "there is no public items".
But autodoc considers all items on the module are public.  This changes
the behavior to correct one.
2020-12-28 13:53:56 +09:00
Takeshi KOMIYA
b19bce971e
Merge pull request #8593 from tk0miya/8592_meta_public_doesnt_affect_to_variables
Fix #8592: autodoc: `:meta public:` does not effect to variables
2020-12-28 13:51:50 +09:00
Takeshi KOMIYA
556b9743fe
Merge pull request #8596 from tk0miya/8022_meta_hide_value
Close #8022: autodoc: Allow to hide the value of the variables via metadata
2020-12-28 12:15:56 +09:00
Takeshi KOMIYA
ce52a90d92 Fix #8592: autodoc: :meta public: does not effect to variables
To control the visibility of variables, ModuleDocumenter have to load
docstring of them on `get_object_members()` phase.  This reimplements
it and `get_module_members()` helper to fetch docstring on earlier
phase (as ClassDocumenter does).
2020-12-27 22:21:34 +09:00
Takeshi KOMIYA
c86e92cb95 Fix #8306: autosummary: mocked modules are documented as empty page
The :recursive: option for autosummary directive creates an empty page
for mocked modules unexpectedly.  This make them ignored.
2020-12-27 21:45:15 +09:00
Takeshi KOMIYA
9e9e486e65 Close #8022: autodoc: Allow to hide the value of the variables via metadata
autodata and autoattribute directives does not show right-hand value of
the variable if its docstring contains ``:meta hide-value:`` in
info-field-list.
2020-12-27 12:46:03 +09:00
Takeshi KOMIYA
6c645e41f8 refactor: Deprecate no_docstring argument for Documenter.add_content()
Deprecate `no_docstring` argument for `Documenter.add_content()` again.

At the first trial (#8533), it changes the behavior of
`autodoc-process-docstring` event; it is emitted unexpectedly for an
alias of class.  But it brings an incompatible change to extensions.
Hence it was partially reverted at #8581.

This keeps not calling the event for an alias of class.  To do that,
now `Documenter.get_doc()` can return None value.
2020-12-26 21:14:26 +09:00
Takeshi KOMIYA
a18fee24f2
Merge pull request #8572 from mitya57/fix-hebrew-in-test
Fix name of the Hebrew language in test_create_single_index
2020-12-23 23:18:54 +09:00
François Freitag
a1b8b1febb
Ensure linkcheck items are comparable
Linkcheck organizes the URLs to checks in a PriorityQueue. The items are
tuples (priority, url, docname, lineno).

Tuples where the lineno is `None` are not comparable with tuples that
have an integer lineno, and PriorityQueue items must be comparable (see
https://bugs.python.org/issue31145).

Fixes an issue when a document contains two links to the same URL, one
with an int line number and the other without line number metadata (such
as an image :target: attribute).

Using 0 instead of None to represent no line number should not lead to
observable changes, the result logger only logs the line number when it
is truthy.

Close #8565
2020-12-22 21:18:31 +01:00
Takeshi KOMIYA
70bb2262d6 Fix #8567: autodoc: Instance attributes are incorrectly added to Parent class
The instance attributes on subclasses are shown on the document of
parent class unexpectedly because of autodoc modifies `__annotations__`
in place.  This fix creates a copy of `__annotations__` attribute and
attach it to the subclass.
2020-12-22 02:38:31 +09:00
Dmitry Shachnev
5b779b4201 Fix name of the Hebrew language in test_create_single_index 2020-12-21 20:12:34 +03:00
Takeshi KOMIYA
423e7ab2ca Fix #8559: AttributeError is raised when using ForwardRef
The restify() helper crashes when ForwardRef is passed.
2020-12-22 00:37:02 +09:00
Takeshi KOMIYA
a7a77d154b Merge branch '3.x' 2020-12-20 21:33:57 +09:00
Takeshi KOMIYA
6e8ea8572f
Merge pull request #8552 from tk0miya/8236_napoleon_receives_section
Close #8236: napoleon: Support numpydoc's "Receives" section
2020-12-20 13:54:01 +09:00
Takeshi KOMIYA
7f1284f2e7
Merge pull request #8555 from tk0miya/8512_test_comment
test: Add comment for UnicodeEncodeError handler (refs: #8512)
2020-12-20 13:53:24 +09:00
Takeshi KOMIYA
2fa15e9396
Merge pull request #8551 from tk0miya/8365_pydomain_xref_missing_context
Fix #8365: py domain: :type: and :rtype: gives false ambiguous warnings
2020-12-20 13:49:53 +09:00
Takeshi KOMIYA
9a9d7f3f00 test: Add comment for UnicodeEncodeError handler (refs: #8512) 2020-12-20 01:01:59 +09:00
Takeshi KOMIYA
aae2f19911
Merge pull request #8512 from jbms/fix-nonascii_srcdir
Fix nonascii_srcdir to work when non-ascii directories aren't supported
2020-12-20 00:58:08 +09:00
Takeshi KOMIYA
f50b999911 Close #8236: napoleon: Support numpydoc's "Receives" section 2020-12-19 20:29:00 +09:00
Takeshi KOMIYA
30c594fbc5 Fix #8365: py domain: :type: and :rtype: gives false ambiguous warnings
The searching context like py:module and py:class are missing in the
pending_xref nodes generated from info-field-lists.  This sets these
searching context info to them.
2020-12-19 18:42:01 +09:00
Takeshi KOMIYA
c0678a4a50 Fix #741: autodoc: inherited-members doesn't support instance attributes on super class
To support instance attributes on super class, get_class_members() scans
the instance attributes defined at super classes using ModuleAnalyzer.
It allows to generate document for them when users gives :
inherited-members: option.
2020-12-18 23:24:59 +09:00
Takeshi KOMIYA
dd1615c59d
Merge pull request #8543 from tk0miya/8534_autoattribute_alias_derived
Fix #8534: autoattribute failed to document a commented attribute in alias dervied class
2020-12-17 22:35:35 +09:00
Takeshi KOMIYA
9721327989 Fix #8545: autodoc: a __slots__ attribute is not documented even having docstring
To avoid filtering __slots__ attributes having docstring at
filter_members(), this passes docstring captured at get_class_members()
to the filter_members() via ObjectMember.
2020-12-17 22:19:28 +09:00
Takeshi KOMIYA
0dbbf1dd54 Fix #8534: autoattribute failed to document a commented attribute in alias dervied class 2020-12-17 22:13:20 +09:00
Takeshi KOMIYA
55c110f609 Fix #8541: autodoc_type_aliases doesn't work for the instance attrs
So far, autodoc obtains type annotations of instance attributes by
ModuleAnalyzer directly.  As a result, autodoc_type_aliases are ignored
for these variables.

This goes to merge type annotations from the class itself and
ModuleAnalyzer's, and get type annotations using `typing.get_type_hints()`
to apply autodoc_type_aliases.
2020-12-17 01:07:54 +09:00
Takeshi KOMIYA
caa1d1f3c2 Fix #8534: autoattribute failed to document a commented attribute in alias class
So far, autoattribute uses "given class name" to fetch comments of
uninitialized instance attributes.  But pycode expects to use "real"
class name on searching attribute comments.

This adds UninitializedInstanceAttributeMixin to handle it simply.
2020-12-16 02:43:31 +09:00
Takeshi KOMIYA
2c98e909bf Merge branch '3.x' 2020-12-14 02:02:29 +09:00
Takeshi KOMIYA
0b074c9e48 Merge commit 'a82b06f2abb1226d82b18e3f85bdf19be7b9eb3f' 2020-12-14 01:58:23 +09:00
Jon Dufresne
850512090a Remove duplicate test in test_ext_autodoc.py
Duplicate since c6bd84a614.
2020-12-12 06:28:23 -08:00
Jeremy Maitin-Shepard
d737ecd063 Fix nonascii_srcdir to work when non-ascii directories aren't supported
Previously, the nonascii_srcdir in tests/test_build.py contained some
logic to attempt to handle the case where non-ascii directories aren't
supported, but it did not actually work because it fails to copy the
test sources to the temporary directory.

With this commit, the following test invocation, which previously
failed, now pases:

LANG=en_US.iso8859-1 python -m pytest test_build.py
2020-11-30 13:13:01 -08:00
Takeshi KOMIYA
9cf2826491
Merge pull request #8506 from tk0miya/8352_option_startswith_bracket
Fix #8352: std domain: Failed to parse an option that starts with bracket
2020-11-29 23:58:18 +09:00
Takeshi KOMIYA
1d9eeedde3 Fix #8508: LaTeX: uplatex becomes a default setting of latex_engine for Japanese
Since v2.3, Sphinx supports uplatex as an alternative of latex_engine for Japanese
docs (refs: #4186, #6841). uplatex is able to build a document without conversion
character encoding internally. It allows using unicode characters in documents.
Additionally, uplatex is compatible with platex (current default latex_engine for
Japanese docs).

This changes the default latex_engine for Japanese document to uplatex.
2020-11-29 15:09:49 +09:00
Takeshi KOMIYA
bb63f03034 Fix #8503: autoattribute could not create document for a GenericAlias 2020-11-29 12:24:10 +09:00
Takeshi KOMIYA
c15c61ed64
Merge pull request #8505 from tk0miya/8501_extract_summary_el_at
Fix #8501: autosummary: summary extraction splits text after "el at."
2020-11-29 11:48:55 +09:00
Takeshi KOMIYA
6d24579f40 Fix #8352: std domain: Failed to parse an option that starts with bracket 2020-11-29 02:22:40 +09:00
Takeshi KOMIYA
3f3358b38f
Merge pull request #8494 from timoludwig/alias-of-builtin
Use restify() to reference alias attributes in autodoc
2020-11-28 22:55:27 +09:00
Timo Ludwig
ccfd98dc07
Fix #8493: Use restify() in autodoc to reference alias attributes 2020-11-28 12:12:02 +01:00
Takeshi KOMIYA
da4c69c624
Merge pull request #8291 from QuentinSoubeyran/8285_napoleon_google_style_use_annotations
Fix #8285: napoleon can use PEP526 annotations
2020-11-28 18:11:30 +09:00
Takeshi KOMIYA
65ca7aa0c9 Fix #8501: autosummary: summary extraction splits text after "el at."
Add "el at." to the list of abbreviations.
2020-11-28 11:41:06 +09:00
Jon Dufresne
c1437d5f79 Replace modify_env() with pytest monkeypatch.setenv()
The same test utility function is built into pytest. Can avoid the
duplication.

https://docs.pytest.org/en/latest/monkeypatch.html#monkeypatching-environment-variables
2020-11-27 14:10:36 -08:00
François Freitag
236afac7fd
Unset env variables in tests by del os.environ
The `unsetenv()` operation does not update `os.environ`.
https://docs.python.org/3/library/os.html#os.unsetenv
2020-11-26 21:12:28 +01:00
François Freitag
6b90a63f08 Fix #6629: linkcheck: Handle rate-limiting
Follow the Retry-After header if present, otherwise use an exponential
back-off.
2020-11-25 17:34:55 +01:00
Quentin Soubeyran
c37ef640a7 rebased on upstream/3.x; fixed CI 2020-11-25 08:49:57 +01:00
Quentin Soubeyran
ec62bf86fa implemented feature in numpy style, factored common code 2020-11-25 08:45:25 +01:00
Quentin Soubeyran
ec30f77712 refactored code and tests, prepared for numpy feature 2020-11-25 08:45:25 +01:00
Quentin Soubeyran
a60e1c10b7 sorted imports 2020-11-25 08:45:25 +01:00
Quentin Soubeyran
8995f15710 moved python 3.6+ syntax test data to standalone file 2020-11-25 08:45:25 +01:00
Quentin Soubeyran
f268665292 added napoleon_google_attr_annotations option to use PEP 526 on google style 2020-11-25 08:45:25 +01:00
Takeshi KOMIYA
c941406415 refactor with pyupgrade
Run `pyupgrade --py3-only --keep-percent-format` to refine our code.

Note:  --keep-percent-format is required to keep translations available.
2020-11-25 01:55:30 +09:00
Takeshi KOMIYA
c941b9cb14
Merge pull request #8481 from tk0miya/8480_slots_attributes
Fix #8480: autoattribute could not create document for __slots__ attributes
2020-11-24 21:53:48 +09:00
Takeshi KOMIYA
3e9200dab4
Merge pull request #8474 from tk0miya/8360_update_warning_for_numref
Fix #8360: Update warning message for numref
2020-11-24 21:38:04 +09:00
Takeshi KOMIYA
0131f776fb
Merge pull request #8475 from tk0miya/8131_too_many_redirects
Extend linkchecker GET fallback logic to handle Too Many Redirects
2020-11-23 17:16:51 +09:00
Takeshi KOMIYA
50dad211ed Fix #8480: autoattribute could not create document for __slots__ attributes 2020-11-23 15:28:53 +09:00
Takeshi KOMIYA
046c289f76 linkcheck: Add a testcase for infinite redirect loop on HEAD request 2020-11-23 01:52:44 +09:00
Takeshi KOMIYA
478a1567b6 Fix #8360: Update warning message for numref 2020-11-23 01:36:35 +09:00
Takeshi KOMIYA
96fe4c110c Fix #8446: html: consecutive spaces are displayed as single space
In HTML, consecutive spaces are considered as single space by HTML
browsers.  To represent them as is, we have to escape them on rendering
them into HTML.  This starts to escape the whole of desc_signature node.
2020-11-22 23:12:04 +09:00
Takeshi KOMIYA
a00d62c445 Merge branch '3.x' 2020-11-22 16:04:07 +09:00
Takeshi KOMIYA
9eb96d5c79 Fix #8460: autodata directive does not display the detail of TypeVars
The details are only shown when automodule directive is used.  This
allows to document them via other auto* directives.
2020-11-22 13:57:48 +09:00
Takeshi KOMIYA
24a329eebe
Merge pull request #8465 from tk0miya/8460_NewType
Fix #8460: autodoc: Support custom types defined by typing.NewType
2020-11-22 13:47:39 +09:00
Takeshi KOMIYA
8bb31c7e3a
Merge pull request #8469 from tk0miya/refactor_test_ext_autodoc_slots
refactor: Rename example class
2020-11-22 11:42:13 +09:00
Takeshi KOMIYA
b4d4d4e808 refactor: Rename example class 2020-11-22 03:06:03 +09:00
Takeshi KOMIYA
ad804647b5
Merge pull request #8459 from tk0miya/8452_autodoc_type_aliases_with_autodoc_typehints
Fix #8452: autodoc_type_aliases doesn't work with autodoc_typehints
2020-11-22 01:34:31 +09:00
Takeshi KOMIYA
333e7a447e Fix #8452: autodoc_type_aliases doesn't work with autodoc_typehints 2020-11-22 01:26:32 +09:00
Takeshi KOMIYA
6973888294 Support NewType as a class attribute 2020-11-21 23:56:16 +09:00
Takeshi KOMIYA
46a7ea7ada Add NewType support to typing.stringify() and restify() 2020-11-21 23:04:42 +09:00
Takeshi KOMIYA
93d6c212f7 Fix #8460: autodoc: Support custom types defined by typing.NewType
A custom type defined by typing.NewType was rendered as a function
because the generated type is a function having special attributes.
This renders it as a variable.

Note: The module name where the NewType object defined is lost on
generating it.  So it is hard to make cross-reference for these custom
types.
2020-11-21 23:04:42 +09:00
François Freitag
419e145e36
Make tests/ a Python package
Allows relative imports.
2020-11-20 19:43:02 +01:00
Takeshi KOMIYA
a8881cae5f Fix flake8 violations 2020-11-21 01:07:27 +09:00
Takeshi KOMIYA
3a4ae2092a Merge branch '3.x' 2020-11-21 01:01:36 +09:00
Takeshi KOMIYA
dcd8ff544a Fix #8443: autoattribute does not support uninitialized ivars 2020-11-20 22:39:21 +09:00
Takeshi KOMIYA
f344fff55e Fix #8443: autodata directive does not support PEP-526 ivars 2020-11-20 22:38:58 +09:00
Takeshi KOMIYA
3becd56e0e Merge branch '3.x' into 8222_novalue 2020-11-17 23:56:42 +09:00
Takeshi KOMIYA
5df381e8e0
Merge pull request #8435 from tk0miya/8434_autodoc_type_aliases_for_variables
Fix #8434: autodoc_type_aliases does not effect to variables
2020-11-17 22:42:38 +09:00
Takeshi KOMIYA
f203a15141 autodoc: Fix :no-value: option for autoattribute does not work 2020-11-17 22:40:40 +09:00
Takeshi KOMIYA
af04b64906
Merge pull request #8429 from tk0miya/refactor_test_intl
test: Merge testcases having the same name
2020-11-16 02:44:58 +09:00
Takeshi KOMIYA
b615fcca85
Merge pull request #8436 from francoisfreitag/better-certs
linkcheck: Specify subjectAltName in test self-signed certificate
2020-11-16 02:42:34 +09:00
François Freitag
3c4e1c30b1
linkcheck: Specify subjectAltName in test self-signed certificate
Clears warning:

tests/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_cacerts
tests/test_build_linkcheck.py::test_connect_to_selfsigned_with_requests_env_var
  …/venv/lib/python3.8/site-packages/urllib3/connection.py:455: SubjectAltNameWarning: Certificate for localhost has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)
    warnings.warn(
2020-11-15 18:25:39 +01:00
Takeshi KOMIYA
44fbe9da7b Fix #8434: autodoc_type_aliases does not effect to variables 2020-11-16 02:11:15 +09:00
Takeshi KOMIYA
5d8d6275a5
Merge pull request #8423 from tk0miya/getslots
Add sphinx.util.inspect:getslots() to get __slots__ attribute
2020-11-16 02:04:42 +09:00
Takeshi KOMIYA
017698a2c6 test: Fix duplicated testcases 2020-11-16 00:07:36 +09:00
Takeshi KOMIYA
f86366a2df test: Merge testcases having the same name 2020-11-16 00:03:20 +09:00
Takeshi KOMIYA
ba496f4d92
Merge pull request #8431 from francoisfreitag/never-leak-env
tests: Always cleanup when exiting modify_env context manager
2020-11-15 20:42:24 +09:00
François Freitag
5eb74d5c8e
tests: Always cleanup when exiting modify_env context manager
Previously, an exception would leave the environment changed.
2020-11-15 10:25:36 +01:00
Takeshi KOMIYA
e99e2aef15 test: Fix flake8 violations 2020-11-15 17:46:37 +09:00
Takeshi KOMIYA
21a3bd4127 refactor: Fix flake8 violations under tests/ directory 2020-11-15 17:15:40 +09:00
Takeshi KOMIYA
5676fdeb4e Rename :novalue: option to :no-value: option
According to the existing options of autodoc directives, `:novalue:`
option is now renamed to `:no-value:` option.
2020-11-15 14:20:30 +09:00
François Freitag
d453088b58
linkcheck: Prevent REQUESTS_CA_BUNDLE leak in tests
Test `test_connect_to_selfsigned_nonexistent_cert_file` serves two
purposes:
- verify the behavior when the CA bundle file path is incorrect
- flag a leak of REQUESTS_CA_BUNDLE

Assumes that test runs after
`test_connect_to_selfsigned_with_requests_env_var`. Not great, but
better than no testing.
2020-11-14 19:58:02 +01:00
Takeshi KOMIYA
bbb0ea5f12 Add sphinx.util.inspect:getslots() to get __slots__ attribute 2020-11-15 02:30:25 +09:00
Takeshi KOMIYA
a638658510
Merge pull request #8421 from francoisfreitag/test-self-signed
linkcheck: Verify behavior with self-signed certs
2020-11-14 21:15:13 +09:00
François Freitag
10e11f3133
linkcheck: Verify behavior with self-signed certs 2020-11-14 12:59:29 +01:00
François Freitag
99c8765822
linkcheck: Remove unused argument from test_invalid_ssl
Not updated after c90eef1f67.
2020-11-14 12:49:47 +01:00
François Freitag
040a1e7743 linkcheck: test invalid SSL is reported as broken
`linkcheck` logic suggests that SSL errors were originally expected to
be ignored.

Blaming the corresponding lines point to issue #3008: linkcheck to
website with self-signed certificates. That issue was fixed by commit
4c7bec6460, which ignored SSL errors.
Probably because back then, users could not specify a CA bundle.

A broken SSL certificate is a real issue, it should not be ignored.
Users wishing to ignore issues for a specific link can use the
`linkcheck_ignore` option.

The current behavior is to report the site as broken, keep it.
2020-11-12 19:58:04 +01:00
François Freitag
ce9d4c1e68
linkcheck: Rewrite headers tests without mocking
Makes the test more realistic by issuing an HTTP request.
Reduces coupling between test and the code under test.
2020-11-11 21:24:06 +01:00
François Freitag
341b98f794
linkcheck: Rewrite auth tests without mocking
Makes the test more realistic by issuing an HTTP request.
Reduces coupling between test and the code under test.
2020-11-11 21:22:59 +01:00
Takeshi KOMIYA
279e547860 Merge branch '3.x' 2020-11-12 02:50:43 +09:00
François Freitag
53ca608bc0
linkcheck: Test redirect following for HEAD and GET 2020-11-11 18:32:53 +01:00
François Freitag
6ea0a123c6
Rename test-linkcheck-localserver{,-anchor}
Precise the `linkcheck_anchors` option is enabled. Frees the name
`test-linkcheck-localserver` for future tests without that option.
2020-11-11 18:32:52 +01:00
Takeshi KOMIYA
386929ec0f
Merge pull request #8409 from francoisfreitag/linkcheck-tests
linkcheck: Remove unused arguments from tests
2020-11-12 02:17:52 +09:00
Takeshi KOMIYA
68cc0f7e94
Merge pull request #8408 from francoisfreitag/isort
Sort imports with isort
2020-11-12 02:05:13 +09:00