sphinx-codeautolink 0.16.2__tar.gz → 0.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/MANIFEST.in +1 -0
- {sphinx_codeautolink-0.16.2/src/sphinx_codeautolink.egg-info → sphinx_codeautolink-0.17.0}/PKG-INFO +4 -5
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/about.rst +1 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/conf.py +3 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/examples.rst +37 -14
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/index.rst +4 -5
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/reference.rst +23 -4
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/release_notes.rst +20 -0
- sphinx_codeautolink-0.17.0/docs/src/static/custom.css +5 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/pyproject.toml +2 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/readme_pypi.rst +3 -4
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/__init__.py +13 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/__init__.py +15 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/backref.py +13 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/block.py +43 -12
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/directive.py +1 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/resolve.py +2 -1
- sphinx_codeautolink-0.17.0/src/sphinx_codeautolink/static/sphinx-codeautolink.css +13 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0/src/sphinx_codeautolink.egg-info}/PKG-INFO +4 -5
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink.egg-info/SOURCES.txt +28 -11
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/__init__.py +32 -0
- sphinx_codeautolink-0.17.0/tests/extension/fail/no_backreference.txt +9 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/ref_invalid_block_type.txt +2 -2
- sphinx_codeautolink-0.17.0/tests/extension/ref/class_mro_fix.txt +15 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_bazel.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_default.txt +14 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_default_fail.txt +10 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_highlight_language.txt +12 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_highlight_none.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_literal.txt +13 -0
- sphinx_codeautolink-0.16.2/tests/extension/ref/non_python_block.txt → sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_non_python_block.txt +1 -1
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_py3.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_pycon_implicit.txt +24 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_pyi.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_python3.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_sage.txt +13 -0
- sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_starlark.txt +13 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_consumed_non_python.txt +1 -1
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/skip_next_consumed_non_python.txt +1 -1
- sphinx_codeautolink-0.17.0/tests/extension/src/class_mro_fix.py +10 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/LICENSE +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/contributing.rst +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/requirements.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/404.rst +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/example_library.rst +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/docs/src/lib.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/requirements/build +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/requirements/dev +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/requirements/docs +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/requirements/extras +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/requirements/tests +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/setup.cfg +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/cache.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/parse.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/warn.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink.egg-info/dependency_links.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink.egg-info/requires.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink.egg-info/top_level.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/__init__.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/_check.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/concat_invalid.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/custom_block_import_invalid.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/custom_block_syntax_error.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/failed_resolve_invalid_location.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/failed_resolve_no_module.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/failed_resolve_return_type.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/match_block_warning.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/missing_inventory.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/no_module_docs.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/ref_import_star_invalid.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/ref_invalid_syntax.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/ref_invalid_syntax_complex.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/ref_ipython_non-python.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/fail/skip_invalid.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_default.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_off.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_on_across_sections.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_on_breaks.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_section_breaks.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/concat_section_returns_to_global.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/custom_block.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/custom_block_imported.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/empty_project.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/inventory_map_is_needed.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/inventory_map_not_needed.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_doctest.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_doctest.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_extdoctest_doctest.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_extdoctest_doctest.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_extdoctest_testcode.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_extdoctest_testcode.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_ipython.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_ipython.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_ipython3.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_ipython3.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_ipython_directive.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_ipython_directive.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_ipython_directive_comment.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_ipython_directive_comment.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_ipython_syntax.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_ipython_syntax.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_py.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_py.txt +0 -0
- /sphinx_codeautolink-0.16.2/tests/extension/ref/ref_pycon.txt → /sphinx_codeautolink-0.17.0/tests/extension/ref/lexer_pycon.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/line_numbers.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_concatenated.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_global.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_global_multiline.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_global_overwritten.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_multiline.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_multiline_and_arg.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_multiple.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/preface_single.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_assign_targets.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_builtins.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_chain.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_chain_call.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_class_attr.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_class_meth_returns_self.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_class_type_attr.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_decorator.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_fluent_attrs.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_fluent_call.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_func_args.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_func_no_module.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_as.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_from.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_from_complex.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_multiple.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_multiple_libs.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_star.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_import_submodule.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_imported_func.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_imported_func_relocated.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_inherited.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_intersphinx_only.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_invalid_func.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_invalid_typehint.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_optional.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_optional_future.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_shadow_builtin.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/ref_simple.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/search_css_duplicates_removed.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/skip_file.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/skip_next.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/skip_off.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/ref/skip_section.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/src/future_project.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/src/parser_func.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/src/test_project/__init__.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/src/test_project/sub.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_autodoc_empty.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_autodoc_links.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_manual_collapse.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_manual_empty.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_manual_links.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_manual_links_subsection.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/extension/table/tab_no_table.txt +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/__init__.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/_util.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/assign.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/chain.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/match.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tests/parse/scope.py +0 -0
- {sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/tox.ini +0 -0
{sphinx_codeautolink-0.16.2/src/sphinx_codeautolink.egg-info → sphinx_codeautolink-0.17.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: sphinx-codeautolink
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Automatic links from code examples to reference documentation.
|
|
5
5
|
Author-email: Felix Hildén <felix.hilden@gmail.com>
|
|
6
6
|
Maintainer-email: Felix Hildén <felix.hilden@gmail.com>
|
|
@@ -70,7 +70,6 @@ sphinx-codeautolink can be installed from the following sources:
|
|
|
70
70
|
.. code:: sh
|
|
71
71
|
|
|
72
72
|
$ pip install sphinx-codeautolink
|
|
73
|
-
# or, alternatively:
|
|
74
73
|
$ conda install -c conda-forge sphinx-codeautolink
|
|
75
74
|
|
|
76
75
|
Note that the library is in early development, so version pinning is advised.
|
|
@@ -85,9 +84,9 @@ Note that the extension name uses an underscore rather than a hyphen.
|
|
|
85
84
|
]
|
|
86
85
|
|
|
87
86
|
That's it! Now your code examples are linked.
|
|
88
|
-
For ways of concatenating
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
For ways of concatenating examples, setting default import statements,
|
|
88
|
+
or customising link style among other things,
|
|
89
|
+
see the `online documentation <https://sphinx-codeautolink.rtfd.org>`_.
|
|
91
90
|
|
|
92
91
|
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/sphinx-codeautolink
|
|
93
92
|
:alt: Python versions
|
|
@@ -18,7 +18,7 @@ Caveats
|
|
|
18
18
|
-------
|
|
19
19
|
- **Only works with HTML documentation**, disabled otherwise. If the extension
|
|
20
20
|
is off, it silently removes directives that would produce output.
|
|
21
|
-
- **Only processes
|
|
21
|
+
- **Only processes blocks, not inline code**. Sphinx has great tools
|
|
22
22
|
for linking definitions inline, and longer code should be in a block anyway.
|
|
23
23
|
- **Doesn't run example code**. Therefore all possible resolvable types are not
|
|
24
24
|
found, and the runtime correctness of code cannot be validated.
|
|
@@ -21,10 +21,16 @@ be analysed and linked to known reference documentation entries.
|
|
|
21
21
|
|
|
22
22
|
Different import styles are supported, along with all Python syntax.
|
|
23
23
|
Star imports might be particularly handy in code examples.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
|
|
25
|
+
A number of other types of blocks are also supported
|
|
26
|
+
along with standard Sphinx configuration, like:
|
|
27
|
+
|
|
28
|
+
- Literal blocks, the ``.. highlight::`` directive
|
|
29
|
+
and ``highlight_language`` configuration
|
|
30
|
+
- `Doctest blocks <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#doctest-blocks>`_
|
|
31
|
+
- Console blocks using :code:`.. code:: pycon`
|
|
32
|
+
- Including code via :rst:dir:`literalinclude`, but requires using one of the
|
|
33
|
+
`Python Lexers <https://pygments.org/docs/lexers/#pygments.lexers.python.PythonLexer>`_
|
|
28
34
|
|
|
29
35
|
.. code:: pycon
|
|
30
36
|
|
|
@@ -39,7 +45,9 @@ particularly in the reference documentation itself:
|
|
|
39
45
|
|
|
40
46
|
.. autolink-examples:: lib.Knight
|
|
41
47
|
|
|
42
|
-
Such a table is generated with :rst:dir:`autolink-examples
|
|
48
|
+
Such a table is generated with :rst:dir:`autolink-examples`:
|
|
49
|
+
|
|
50
|
+
.. code-block:: rst
|
|
43
51
|
|
|
44
52
|
.. autolink-examples:: lib.Knight
|
|
45
53
|
|
|
@@ -54,14 +62,18 @@ The import can be hidden instead.
|
|
|
54
62
|
|
|
55
63
|
lib.Knight().taunt()
|
|
56
64
|
|
|
57
|
-
The previous block is produced with :rst:dir:`autolink-preface
|
|
65
|
+
The previous block is produced with :rst:dir:`autolink-preface`:
|
|
66
|
+
|
|
67
|
+
.. code-block:: rst
|
|
58
68
|
|
|
59
69
|
.. autolink-preface:: import lib
|
|
60
70
|
.. code:: python
|
|
61
71
|
|
|
62
72
|
lib.Knight().taunt()
|
|
63
73
|
|
|
64
|
-
A multiline preface can be written in the content portion of the directive
|
|
74
|
+
A multiline preface can be written in the content portion of the directive:
|
|
75
|
+
|
|
76
|
+
.. code-block:: rst
|
|
65
77
|
|
|
66
78
|
.. autolink-preface::
|
|
67
79
|
|
|
@@ -90,7 +102,9 @@ the previous left off.
|
|
|
90
102
|
print(knight.taunt())
|
|
91
103
|
knight.scratch()
|
|
92
104
|
|
|
93
|
-
This was achieved with :rst:dir:`autolink-concat
|
|
105
|
+
This was achieved with :rst:dir:`autolink-concat`:
|
|
106
|
+
|
|
107
|
+
.. code-block:: rst
|
|
94
108
|
|
|
95
109
|
.. autolink-concat:: section
|
|
96
110
|
.. code:: python
|
|
@@ -118,7 +132,9 @@ and preventing it from being included in further sources with concatenation.
|
|
|
118
132
|
import lib
|
|
119
133
|
lib.Knight()
|
|
120
134
|
|
|
121
|
-
Which is done via :rst:dir:`autolink-skip
|
|
135
|
+
Which is done via :rst:dir:`autolink-skip`:
|
|
136
|
+
|
|
137
|
+
.. code-block:: rst
|
|
122
138
|
|
|
123
139
|
.. autolink-skip::
|
|
124
140
|
.. code:: python
|
|
@@ -190,7 +206,9 @@ Reference tables across intersphinx work too:
|
|
|
190
206
|
It seems that the reference type information is more important
|
|
191
207
|
for Sphinx when dealing with external modules,
|
|
192
208
|
likely because the references cannot be resolved dynamically.
|
|
193
|
-
Please specify a ``type`` in :rst:dir:`autolink-examples
|
|
209
|
+
Please specify a ``type`` in :rst:dir:`autolink-examples`:
|
|
210
|
+
|
|
211
|
+
.. code-block:: rst
|
|
194
212
|
|
|
195
213
|
.. autolink-examples:: numpy.linspace
|
|
196
214
|
:type: func
|
|
@@ -294,12 +312,12 @@ For example, a transformer could be implemented as follows:
|
|
|
294
312
|
Sometimes links with third-party code blocks are broken.
|
|
295
313
|
See :ref:`about` for a potential solution.
|
|
296
314
|
|
|
315
|
+
.. _examples-css:
|
|
316
|
+
|
|
297
317
|
Custom link styles
|
|
298
318
|
------------------
|
|
299
319
|
If you want a specific style to be applied to code block links,
|
|
300
320
|
you may add your own CSS file to the Sphinx build.
|
|
301
|
-
All code block links use the ``sphinx-codeautolink-a`` class.
|
|
302
|
-
For example, you can add dotted lines to all links and change the hover colour:
|
|
303
321
|
|
|
304
322
|
.. code:: python
|
|
305
323
|
|
|
@@ -307,12 +325,17 @@ For example, you can add dotted lines to all links and change the hover colour:
|
|
|
307
325
|
html_static_path = ['static']
|
|
308
326
|
html_css_files = ['custom.css']
|
|
309
327
|
|
|
328
|
+
To include only in specific documents, see the ``html-page-context`` event
|
|
329
|
+
and the :meth:`Sphinx.add_css_file` function.
|
|
330
|
+
For example, you can add similar underlines as this documentation
|
|
331
|
+
and change the hover colour:
|
|
332
|
+
|
|
310
333
|
.. code:: css
|
|
311
334
|
|
|
312
335
|
/* static/custom.css */
|
|
313
336
|
.sphinx-codeautolink-a{
|
|
314
|
-
border-bottom-color:
|
|
315
|
-
border-bottom-style:
|
|
337
|
+
border-bottom-color: #ccc;
|
|
338
|
+
border-bottom-style: solid;
|
|
316
339
|
border-bottom-width: 1px;
|
|
317
340
|
}
|
|
318
341
|
.sphinx-codeautolink-a:hover{
|
|
@@ -5,7 +5,7 @@ sphinx-codeautolink
|
|
|
5
5
|
sphinx-codeautolink makes code examples clickable by inserting links
|
|
6
6
|
from individual code elements to the corresponding reference documentation.
|
|
7
7
|
We aim for a minimal setup assuming your examples are already valid Python.
|
|
8
|
-
Click any
|
|
8
|
+
Click any undelined name in the example below for a demonstration:
|
|
9
9
|
|
|
10
10
|
.. code:: python
|
|
11
11
|
|
|
@@ -42,7 +42,6 @@ sphinx-codeautolink can be installed from the following sources:
|
|
|
42
42
|
.. code:: sh
|
|
43
43
|
|
|
44
44
|
$ pip install sphinx-codeautolink
|
|
45
|
-
# or, alternatively:
|
|
46
45
|
$ conda install -c conda-forge sphinx-codeautolink
|
|
47
46
|
|
|
48
47
|
To enable sphinx-codeautolink, modify the extension list in ``conf.py``.
|
|
@@ -56,8 +55,8 @@ Note that the extension name uses an underscore rather than a hyphen.
|
|
|
56
55
|
]
|
|
57
56
|
|
|
58
57
|
That's it! Now your code examples are linked.
|
|
59
|
-
For ways of concatenating
|
|
60
|
-
|
|
58
|
+
For ways of concatenating examples, setting default import statements,
|
|
59
|
+
or customising link style among other things,
|
|
61
60
|
have a look at the :ref:`reference` documentation.
|
|
62
61
|
|
|
63
62
|
sphinx-codeautolink elsewhere:
|
|
@@ -70,7 +69,7 @@ Caveats
|
|
|
70
69
|
For a more thorough explanation, see :ref:`about`.
|
|
71
70
|
|
|
72
71
|
- Only works with HTML documentation
|
|
73
|
-
- Only processes
|
|
72
|
+
- Only processes blocks, not inline code
|
|
74
73
|
- Doesn't run example code
|
|
75
74
|
- Parsing and type hint resolving is incomplete
|
|
76
75
|
|
|
@@ -57,14 +57,27 @@ Configuration
|
|
|
57
57
|
|
|
58
58
|
.. confval:: codeautolink_warn_on_missing_inventory
|
|
59
59
|
|
|
60
|
-
Type: ``bool``.
|
|
60
|
+
Type: ``bool``. Warn when an object cannot be found in
|
|
61
61
|
the inventory (autodoc or intersphinx). Defaults to :code:`False`.
|
|
62
62
|
|
|
63
63
|
.. confval:: codeautolink_warn_on_failed_resolve
|
|
64
64
|
|
|
65
|
-
Type: ``bool``.
|
|
65
|
+
Type: ``bool``. Warn when failing to resolve the canonical location
|
|
66
66
|
of an object that a code element references. Defaults to :code:`False`.
|
|
67
67
|
|
|
68
|
+
.. confval:: codeautolink_warn_on_no_backreference
|
|
69
|
+
|
|
70
|
+
Type: ``bool``. Warn when no backreference could be found
|
|
71
|
+
from reference documentation using the :rst:dir:`autolink-examples` table.
|
|
72
|
+
This highlights objects for which no tutorial, example or how-to exists.
|
|
73
|
+
Defaults to :code:`False`.
|
|
74
|
+
|
|
75
|
+
.. confval:: codeautolink_warn_on_default_parse_fail
|
|
76
|
+
|
|
77
|
+
Type: ``bool``. Warn when a code block using the ``default`` lexer
|
|
78
|
+
cannot be parsed as Python. By default these cases are ignored by the
|
|
79
|
+
syntax highlighter, so we match the behavior. Defaults to :code:`False`.
|
|
80
|
+
|
|
68
81
|
Directives
|
|
69
82
|
----------
|
|
70
83
|
.. rst:directive:: .. autolink-examples:: object
|
|
@@ -89,7 +102,7 @@ Directives
|
|
|
89
102
|
|
|
90
103
|
.. rst:directive:: .. autolink-concat:: [mode]
|
|
91
104
|
|
|
92
|
-
Toggle
|
|
105
|
+
Toggle block concatenation.
|
|
93
106
|
Concatenated code blocks are treated as a continuous source,
|
|
94
107
|
so that imports and statements in previous blocks affect later blocks.
|
|
95
108
|
Concatenation is begun at the directive, not applied retroactively.
|
|
@@ -115,7 +128,7 @@ Directives
|
|
|
115
128
|
Skip sphinx-codeautolink functionality.
|
|
116
129
|
``level``, if specified, must be one of:
|
|
117
130
|
|
|
118
|
-
- "next" - next block (default)
|
|
131
|
+
- "next" - next encountered block (default)
|
|
119
132
|
- "section" - blocks until the next title
|
|
120
133
|
- "file" - all blocks in the current file
|
|
121
134
|
- "off" - turn skipping off
|
|
@@ -124,10 +137,16 @@ Directives
|
|
|
124
137
|
it is not processed (e.g. non-Python blocks) to avoid placement confusion.
|
|
125
138
|
Skipped blocks are ignored in block concatenation as well, and concatenation
|
|
126
139
|
is resumed without breaks after skipping is over.
|
|
140
|
+
"Next" doesn't need to be specified right before the block that would consume
|
|
141
|
+
it. For e.g. literal blocks the skip directive would be inserted before the
|
|
142
|
+
preceding paragraph.
|
|
127
143
|
|
|
128
144
|
CSS class
|
|
129
145
|
---------
|
|
130
146
|
The CSS class used in all code block links is ``sphinx-codeautolink-a``.
|
|
147
|
+
By default, the links only have a light blue hover colour.
|
|
148
|
+
The style has been made more obvious in the documentation for demonstration.
|
|
149
|
+
See :ref:`examples-css` for more information.
|
|
131
150
|
|
|
132
151
|
Cleanup functions
|
|
133
152
|
-----------------
|
|
@@ -8,6 +8,26 @@ These release notes are based on
|
|
|
8
8
|
sphinx-codeautolink adheres to
|
|
9
9
|
`Semantic Versioning <https://semver.org>`_.
|
|
10
10
|
|
|
11
|
+
0.17.0 (2025-02-18)
|
|
12
|
+
-------------------
|
|
13
|
+
Added
|
|
14
|
+
*****
|
|
15
|
+
- Add more Pygments lexer aliases in code blocks (:issue:`160`)
|
|
16
|
+
- Introduce :confval:`codeautolink_warn_on_no_backreference` to highlight
|
|
17
|
+
where reference documentation does not appear to have
|
|
18
|
+
a corresponding tutorial or how-to (:issue:`161`)
|
|
19
|
+
- Support the ``default`` lexer, literal blocks, ``.. highlight::`` directive
|
|
20
|
+
and ``highlight_language`` configuration (:issue:`166`)
|
|
21
|
+
- Add :confval:`codeautolink_warn_on_default_parse_fail` to warn about
|
|
22
|
+
failing to link code blocks without a language parameter (:issue:`166`)
|
|
23
|
+
- Detect and implicitly use ``pycon`` lexer for blocks that look like
|
|
24
|
+
console code (:issue:`168`)
|
|
25
|
+
|
|
26
|
+
Fixed
|
|
27
|
+
*****
|
|
28
|
+
- Fix undocumented class attribute leading to a crash (:issue:`165`)
|
|
29
|
+
- Fix skipping blocks with identical content to linked ones (:issue:`172`)
|
|
30
|
+
|
|
11
31
|
0.16.2 (2025-01-16)
|
|
12
32
|
-------------------
|
|
13
33
|
- Fix regression in not handling malformed return types (:issue:`159`)
|
|
@@ -75,6 +75,7 @@ extend-ignore = [
|
|
|
75
75
|
"COM812", # recommended by ruff format
|
|
76
76
|
"ISC001", # recommended by ruff format
|
|
77
77
|
"PLR0913", # many arguments is fine
|
|
78
|
+
"PLR0915", # many statements is fine
|
|
78
79
|
]
|
|
79
80
|
extend-unsafe-fixes = ["F401"]
|
|
80
81
|
isort.split-on-trailing-comma = false
|
|
@@ -88,6 +89,7 @@ isort.split-on-trailing-comma = false
|
|
|
88
89
|
"ANN", # annotations
|
|
89
90
|
"S101", # assertions - necessary in tests
|
|
90
91
|
"T201", # print - helpful in tests
|
|
92
|
+
"PLR2004", # magic number
|
|
91
93
|
]
|
|
92
94
|
# TODO: support future annotated hints properly
|
|
93
95
|
"tests/extension/src/test_project/__init__.py" = ["FA100"]
|
|
@@ -16,7 +16,6 @@ sphinx-codeautolink can be installed from the following sources:
|
|
|
16
16
|
.. code:: sh
|
|
17
17
|
|
|
18
18
|
$ pip install sphinx-codeautolink
|
|
19
|
-
# or, alternatively:
|
|
20
19
|
$ conda install -c conda-forge sphinx-codeautolink
|
|
21
20
|
|
|
22
21
|
Note that the library is in early development, so version pinning is advised.
|
|
@@ -31,9 +30,9 @@ Note that the extension name uses an underscore rather than a hyphen.
|
|
|
31
30
|
]
|
|
32
31
|
|
|
33
32
|
That's it! Now your code examples are linked.
|
|
34
|
-
For ways of concatenating
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
For ways of concatenating examples, setting default import statements,
|
|
34
|
+
or customising link style among other things,
|
|
35
|
+
see the `online documentation <https://sphinx-codeautolink.rtfd.org>`_.
|
|
37
36
|
|
|
38
37
|
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/sphinx-codeautolink
|
|
39
38
|
:alt: Python versions
|
{sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/__init__.py
RENAMED
|
@@ -5,7 +5,7 @@ from sphinx.application import Sphinx
|
|
|
5
5
|
from .extension import SphinxCodeAutoLink, backref, directive
|
|
6
6
|
from .extension.block import clean_ipython, clean_pycon
|
|
7
7
|
|
|
8
|
-
__version__ = "0.
|
|
8
|
+
__version__ = "0.17.0"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def setup(app: Sphinx):
|
|
@@ -43,6 +43,18 @@ def setup(app: Sphinx):
|
|
|
43
43
|
rebuild="html",
|
|
44
44
|
types=[bool],
|
|
45
45
|
)
|
|
46
|
+
app.add_config_value(
|
|
47
|
+
"codeautolink_warn_on_no_backreference",
|
|
48
|
+
default=False,
|
|
49
|
+
rebuild="html",
|
|
50
|
+
types=[bool],
|
|
51
|
+
)
|
|
52
|
+
app.add_config_value(
|
|
53
|
+
"codeautolink_warn_on_default_parse_fail",
|
|
54
|
+
default=False,
|
|
55
|
+
rebuild="html",
|
|
56
|
+
types=[bool],
|
|
57
|
+
)
|
|
46
58
|
|
|
47
59
|
app.add_directive("autolink-concat", directive.Concat)
|
|
48
60
|
app.add_directive("autolink-examples", directive.Examples)
|
|
@@ -74,6 +74,9 @@ class SphinxCodeAutoLink:
|
|
|
74
74
|
self.inventory_map: dict[str, str] = {}
|
|
75
75
|
self.warn_missing_inventory = None
|
|
76
76
|
self.warn_failed_resolve = None
|
|
77
|
+
self.warn_no_backreference = None
|
|
78
|
+
self.warn_default_parse_fail = None
|
|
79
|
+
self.highlight_lang = None
|
|
77
80
|
|
|
78
81
|
# Populated once
|
|
79
82
|
self.outdated_docs: set[str] = set()
|
|
@@ -103,6 +106,11 @@ class SphinxCodeAutoLink:
|
|
|
103
106
|
self.inventory_map = app.config.codeautolink_inventory_map
|
|
104
107
|
self.warn_missing_inventory = app.config.codeautolink_warn_on_missing_inventory
|
|
105
108
|
self.warn_failed_resolve = app.config.codeautolink_warn_on_failed_resolve
|
|
109
|
+
self.warn_no_backreference = app.config.codeautolink_warn_on_no_backreference
|
|
110
|
+
self.warn_default_parse_fail = (
|
|
111
|
+
app.config.codeautolink_warn_on_default_parse_fail
|
|
112
|
+
)
|
|
113
|
+
self.highlight_lang = app.config.highlight_language
|
|
106
114
|
|
|
107
115
|
# Append static resources path so references in setup() are valid
|
|
108
116
|
app.config.html_static_path.append(
|
|
@@ -136,6 +144,8 @@ class SphinxCodeAutoLink:
|
|
|
136
144
|
global_preface=self.global_preface,
|
|
137
145
|
custom_blocks=self.custom_blocks,
|
|
138
146
|
concat_default=self.concat_default,
|
|
147
|
+
default_highlight_lang=self.highlight_lang,
|
|
148
|
+
warn_default_parse_fail=self.warn_default_parse_fail,
|
|
139
149
|
)
|
|
140
150
|
doctree.walkabout(visitor)
|
|
141
151
|
self.cache.transforms[visitor.current_document] = visitor.source_transforms
|
|
@@ -255,7 +265,11 @@ class SphinxCodeAutoLink:
|
|
|
255
265
|
rm_vis = RemoveExtensionVisitor(doctree)
|
|
256
266
|
return doctree.walkabout(rm_vis)
|
|
257
267
|
|
|
258
|
-
visitor = CodeRefsVisitor(
|
|
268
|
+
visitor = CodeRefsVisitor(
|
|
269
|
+
doctree,
|
|
270
|
+
code_refs=self.code_refs,
|
|
271
|
+
warn_no_backreference=self.warn_no_backreference,
|
|
272
|
+
)
|
|
259
273
|
doctree.walk(visitor)
|
|
260
274
|
return None
|
|
261
275
|
|
|
@@ -4,6 +4,8 @@ from dataclasses import dataclass
|
|
|
4
4
|
|
|
5
5
|
from docutils import nodes
|
|
6
6
|
|
|
7
|
+
from sphinx_codeautolink.warn import logger, warn_type
|
|
8
|
+
|
|
7
9
|
from .directive import DeferredExamples
|
|
8
10
|
|
|
9
11
|
|
|
@@ -56,10 +58,15 @@ class CodeRefsVisitor(nodes.SparseNodeVisitor):
|
|
|
56
58
|
"""Replace :class:`DeferredCodeReferences` with table of concrete references."""
|
|
57
59
|
|
|
58
60
|
def __init__(
|
|
59
|
-
self,
|
|
61
|
+
self,
|
|
62
|
+
*args,
|
|
63
|
+
code_refs: dict[str, list[CodeExample]],
|
|
64
|
+
warn_no_backreference: bool = False,
|
|
65
|
+
**kwargs,
|
|
60
66
|
) -> None:
|
|
61
67
|
super().__init__(*args, **kwargs)
|
|
62
68
|
self.code_refs = code_refs
|
|
69
|
+
self.warn_no_backreference = warn_no_backreference
|
|
63
70
|
|
|
64
71
|
def unknown_departure(self, node) -> None:
|
|
65
72
|
"""Ignore unknown nodes."""
|
|
@@ -79,6 +86,11 @@ class CodeRefsVisitor(nodes.SparseNodeVisitor):
|
|
|
79
86
|
items = sorted(set(items))
|
|
80
87
|
|
|
81
88
|
if not items:
|
|
89
|
+
if self.warn_no_backreference:
|
|
90
|
+
msg = f"No backreference for: '{node.ref}'"
|
|
91
|
+
logger.warning(
|
|
92
|
+
msg, type=warn_type, subtype="no_backreference", location=node
|
|
93
|
+
)
|
|
82
94
|
# Remove surrounding paragraph too
|
|
83
95
|
node.parent.parent.remove(node.parent)
|
|
84
96
|
return
|
{sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0}/src/sphinx_codeautolink/extension/block.py
RENAMED
|
@@ -17,7 +17,18 @@ from sphinx_codeautolink.warn import logger, warn_type
|
|
|
17
17
|
from .backref import CodeExample
|
|
18
18
|
from .directive import ConcatMarker, PrefaceMarker, SkipMarker
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
# list from https://pygments.org/docs/lexers/#pygments.lexers.python.PythonLexer
|
|
21
|
+
BUILTIN_BLOCKS = {
|
|
22
|
+
"default": None,
|
|
23
|
+
"python": None,
|
|
24
|
+
"python3": None,
|
|
25
|
+
"py": None,
|
|
26
|
+
"py3": None,
|
|
27
|
+
"pyi": None,
|
|
28
|
+
"sage": None,
|
|
29
|
+
"bazel": None,
|
|
30
|
+
"starlark": None,
|
|
31
|
+
}
|
|
21
32
|
|
|
22
33
|
|
|
23
34
|
@dataclass
|
|
@@ -94,7 +105,7 @@ else:
|
|
|
94
105
|
|
|
95
106
|
|
|
96
107
|
class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
97
|
-
"""Transform
|
|
108
|
+
"""Transform blocks of Python with links to reference documentation."""
|
|
98
109
|
|
|
99
110
|
def __init__(
|
|
100
111
|
self,
|
|
@@ -103,6 +114,8 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
103
114
|
global_preface: list[str],
|
|
104
115
|
custom_blocks: dict[str, Callable[[str], str]],
|
|
105
116
|
concat_default: bool,
|
|
117
|
+
default_highlight_lang: str | None,
|
|
118
|
+
warn_default_parse_fail: bool,
|
|
106
119
|
**kwargs,
|
|
107
120
|
) -> None:
|
|
108
121
|
super().__init__(*args, **kwargs)
|
|
@@ -120,6 +133,8 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
120
133
|
self.concat_section = False
|
|
121
134
|
self.concat_sources = []
|
|
122
135
|
self.skip = None
|
|
136
|
+
self.highlight_lang = default_highlight_lang
|
|
137
|
+
self.warn_default_parse_fail = warn_default_parse_fail
|
|
123
138
|
|
|
124
139
|
def unknown_visit(self, node) -> None:
|
|
125
140
|
"""Handle and delete custom directives, ignore others."""
|
|
@@ -152,6 +167,10 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
152
167
|
def unknown_departure(self, node) -> None:
|
|
153
168
|
"""Ignore unknown nodes."""
|
|
154
169
|
|
|
170
|
+
def visit_highlightlang(self, node) -> None:
|
|
171
|
+
"""Set expected highlight language."""
|
|
172
|
+
self.highlight_lang = node["lang"]
|
|
173
|
+
|
|
155
174
|
def visit_title(self, node) -> None:
|
|
156
175
|
"""Track section names and break concatenation and skipping."""
|
|
157
176
|
self.title_stack.append(node.astext())
|
|
@@ -175,9 +194,9 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
175
194
|
|
|
176
195
|
def visit_literal_block(self, node: nodes.literal_block):
|
|
177
196
|
"""Visit a generic literal block."""
|
|
178
|
-
return self.parse_source(node, node.get("language",
|
|
197
|
+
return self.parse_source(node, node.get("language", self.highlight_lang))
|
|
179
198
|
|
|
180
|
-
def parse_source(
|
|
199
|
+
def parse_source( # noqa: C901
|
|
181
200
|
self, node: nodes.literal_block | nodes.doctest_block, language: str | None
|
|
182
201
|
) -> None:
|
|
183
202
|
"""Analyse Python code blocks."""
|
|
@@ -189,14 +208,27 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
189
208
|
self.skip = None
|
|
190
209
|
|
|
191
210
|
if (
|
|
192
|
-
|
|
193
|
-
or len(node.children) != 1
|
|
211
|
+
len(node.children) != 1
|
|
194
212
|
or not isinstance(node.children[0], nodes.Text)
|
|
195
213
|
or language not in self.valid_blocks
|
|
196
214
|
):
|
|
197
215
|
return
|
|
198
216
|
|
|
199
217
|
source = node.children[0].astext()
|
|
218
|
+
example = CodeExample(
|
|
219
|
+
self.current_document, self.current_refid, list(self.title_stack)
|
|
220
|
+
)
|
|
221
|
+
transform = SourceTransform(source, [], example, node.line)
|
|
222
|
+
self.source_transforms.append(transform)
|
|
223
|
+
|
|
224
|
+
if skip:
|
|
225
|
+
return
|
|
226
|
+
|
|
227
|
+
# Sphinx uses a similar trick to use pycon implicitly (#168)
|
|
228
|
+
pycon_candidates = ("py", "python", "py3", "python3", "default", "pycon3")
|
|
229
|
+
if source.startswith(">>>") and language in pycon_candidates:
|
|
230
|
+
language = "pycon"
|
|
231
|
+
|
|
200
232
|
transformer = self.transformers[language]
|
|
201
233
|
if transformer:
|
|
202
234
|
try:
|
|
@@ -209,11 +241,7 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
209
241
|
return
|
|
210
242
|
else:
|
|
211
243
|
clean_source = source
|
|
212
|
-
|
|
213
|
-
self.current_document, self.current_refid, list(self.title_stack)
|
|
214
|
-
)
|
|
215
|
-
transform = SourceTransform(source, [], example, node.line)
|
|
216
|
-
self.source_transforms.append(transform)
|
|
244
|
+
transform.source = source
|
|
217
245
|
|
|
218
246
|
modified_source = "\n".join(
|
|
219
247
|
self.global_preface + self.concat_sources + prefaces + [clean_source]
|
|
@@ -221,8 +249,11 @@ class CodeBlockAnalyser(nodes.SparseNodeVisitor):
|
|
|
221
249
|
try:
|
|
222
250
|
names = parse_names(modified_source, node)
|
|
223
251
|
except SyntaxError as e:
|
|
252
|
+
if language == "default" and not self.warn_default_parse_fail:
|
|
253
|
+
return
|
|
254
|
+
|
|
224
255
|
show_source = self._format_source_for_error(
|
|
225
|
-
self.global_preface, self.concat_sources, prefaces, source
|
|
256
|
+
self.global_preface, self.concat_sources, prefaces, transform.source
|
|
226
257
|
)
|
|
227
258
|
msg = self._parsing_error_msg(e, language, show_source)
|
|
228
259
|
logger.warning(msg, type=warn_type, subtype="parse_block", location=node)
|
|
@@ -86,8 +86,9 @@ def locate_type(cursor: Cursor, components: tuple[str, ...], inventory) -> Curso
|
|
|
86
86
|
with suppress(AttributeError, TypeError):
|
|
87
87
|
cursor.location = fully_qualified_name(cursor.value)
|
|
88
88
|
|
|
89
|
+
# Check bases if member not found in current class
|
|
89
90
|
if isclass(previous.value) and cursor.location not in inventory:
|
|
90
|
-
for val in previous.value.__mro__:
|
|
91
|
+
for val in previous.value.__mro__[1:]:
|
|
91
92
|
name = fully_qualified_name(val)
|
|
92
93
|
if name + "." + component in inventory:
|
|
93
94
|
previous.location = name
|
{sphinx_codeautolink-0.16.2 → sphinx_codeautolink-0.17.0/src/sphinx_codeautolink.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: sphinx-codeautolink
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Automatic links from code examples to reference documentation.
|
|
5
5
|
Author-email: Felix Hildén <felix.hilden@gmail.com>
|
|
6
6
|
Maintainer-email: Felix Hildén <felix.hilden@gmail.com>
|
|
@@ -70,7 +70,6 @@ sphinx-codeautolink can be installed from the following sources:
|
|
|
70
70
|
.. code:: sh
|
|
71
71
|
|
|
72
72
|
$ pip install sphinx-codeautolink
|
|
73
|
-
# or, alternatively:
|
|
74
73
|
$ conda install -c conda-forge sphinx-codeautolink
|
|
75
74
|
|
|
76
75
|
Note that the library is in early development, so version pinning is advised.
|
|
@@ -85,9 +84,9 @@ Note that the extension name uses an underscore rather than a hyphen.
|
|
|
85
84
|
]
|
|
86
85
|
|
|
87
86
|
That's it! Now your code examples are linked.
|
|
88
|
-
For ways of concatenating
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
For ways of concatenating examples, setting default import statements,
|
|
88
|
+
or customising link style among other things,
|
|
89
|
+
see the `online documentation <https://sphinx-codeautolink.rtfd.org>`_.
|
|
91
90
|
|
|
92
91
|
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/sphinx-codeautolink
|
|
93
92
|
:alt: Python versions
|