sphinx-scrapy 0.1.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.
@@ -0,0 +1,23 @@
1
+ name: Publish
2
+ on:
3
+ push:
4
+ tags:
5
+ - '[0-9]+.[0-9]+.[0-9]+'
6
+ jobs:
7
+ publish:
8
+ runs-on: ubuntu-latest
9
+ environment:
10
+ name: pypi
11
+ url: https://pypi.org/p/${{ github.event.repository.name }}
12
+ permissions:
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: 3.13
19
+ - run: |
20
+ python -m pip install --upgrade build
21
+ python -m build
22
+ - name: Publish to PyPI
23
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,21 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.11.13
4
+ hooks:
5
+ - id: ruff-check
6
+ args: [ --fix ]
7
+ - id: ruff-format
8
+ - repo: https://github.com/pre-commit/mirrors-mypy
9
+ rev: v1.16.0
10
+ hooks:
11
+ - id: mypy
12
+ - repo: https://github.com/adamchainz/blacken-docs
13
+ rev: 1.19.1
14
+ hooks:
15
+ - id: blacken-docs
16
+ additional_dependencies:
17
+ - black==25.1.0
18
+ - repo: https://github.com/pre-commit/pre-commit-hooks
19
+ rev: v5.0.0
20
+ hooks:
21
+ - id: trailing-whitespace
@@ -0,0 +1,8 @@
1
+ =============
2
+ Release notes
3
+ =============
4
+
5
+ 0.1.0 (2025-06-14)
6
+ ==================
7
+
8
+ Initial release.
@@ -0,0 +1,27 @@
1
+ Copyright (c) Scrapy developers.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions, and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions, and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of Scrapy nor the names of its contributors may be used
15
+ to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.4
2
+ Name: sphinx-scrapy
3
+ Version: 0.1.0
4
+ Summary: Sphinx extension for documentation in the Scrapy ecosystem
5
+ Project-URL: Source, https://github.com/scrapy/sphinx-scrapy
6
+ Project-URL: Tracker, https://github.com/scrapy/sphinx-scrapy/issues
7
+ Project-URL: Release notes, https://github.com/scrapy/sphinx-scrapy/blob/main/CHANGES.rst
8
+ Author-email: Scrapy developers <opensource@zyte.com>
9
+ Maintainer-email: Scrapy developers <opensource@zyte.com>
10
+ License-Expression: BSD-3-Clause
11
+ License-File: LICENSE
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: Scrapy
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Internet :: WWW/HTTP
24
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.9
27
+ Requires-Dist: sphinx
28
+ Description-Content-Type: text/x-rst
29
+
30
+ =============
31
+ sphinx-scrapy
32
+ =============
33
+
34
+ |version| |python_version|
35
+
36
+ .. |version| image:: https://img.shields.io/pypi/v/sphinx-scrapy.svg
37
+ :target: https://pypi.org/pypi/sphinx-scrapy
38
+ :alt: PyPI version
39
+
40
+ .. |python_version| image:: https://img.shields.io/pypi/pyversions/sphinx-scrapy.svg
41
+ :target: https://pypi.org/pypi/sphinx-scrapy
42
+ :alt: Supported Python versions
43
+
44
+ Sphinx_ extension for documentation in the Scrapy_ ecosystem.
45
+
46
+ .. _Sphinx: https://www.sphinx-doc.org/
47
+ .. _Scrapy: https://scrapy.org/
48
+
49
+
50
+ Features
51
+ ========
52
+
53
+ - Automatic configuration of intersphinx_ for Python_ and Scrapy_.
54
+
55
+ Ready-to-use, easy-to-enable configuration for the following packages of
56
+ the Scrapy_ ecosystem is also available:
57
+
58
+ .. _intersphinx: https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
59
+ .. _Python: https://docs.python.org/
60
+
61
+ | `attrs <https://www.attrs.org/en/stable/>`_
62
+ | `cssselect <https://cssselect.readthedocs.io/en/latest>`_
63
+ | `itemloaders <https://itemloaders.readthedocs.io/en/latest/>`_
64
+ | `parsel <https://parsel.readthedocs.io/en/latest/>`_
65
+ | `python-zyte-api <https://python-zyte-api.readthedocs.io/en/stable/>`_
66
+ | `scrapy-poet <https://scrapy-poet.readthedocs.io/en/stable/>`_
67
+ | `tenacity <https://tenacity.readthedocs.io/en/latest>`_
68
+ | `twisted <https://docs.twisted.org/en/stable/>`_ (and `twistedapi <https://docs.twisted.org/en/stable/api/>`_)
69
+ | `w3lib <https://w3lib.readthedocs.io/en/latest/>`_
70
+ | `web-poet <https://web-poet.readthedocs.io/en/stable/>`_
71
+ | `zyte <https://docs.zyte.com>`_
72
+ | `zyte-common-items <https://zyte-common-items.readthedocs.io/en/latest>`_
73
+ | `zyte-spider-templates <https://zyte-spider-templates.readthedocs.io/en/latest>`_
74
+
75
+ To automatically configure intersphinx for any of those packages if
76
+ installed, add to your ``conf.py`` file:
77
+
78
+ .. code-block:: python
79
+
80
+ scrapy_intersphinx_enable_installed = True
81
+
82
+ You can also enable or disable the automatic intersphinx configuration of
83
+ packages manually:
84
+
85
+ .. code-block:: python
86
+
87
+ scrapy_intersphinx_enable = [
88
+ "parsel",
89
+ "w3lib",
90
+ ]
91
+ scrapy_intersphinx_disable = [
92
+ "scrapy",
93
+ ]
94
+
95
+ - Automatic configuration of Sphinx roles of the Scrapy documentation, so
96
+ that you can easily link to Scrapy settings, request metadata keys, signals
97
+ and commands:
98
+
99
+ .. code-block:: rst
100
+
101
+ :setting:`BOT_NAME`
102
+ :setting:`LOG_LEVEL <scrapy:LOG_LEVEL>`
103
+ :reqmeta:`download_slot`
104
+ :signal:`spider_opened`
105
+ :command:`crawl`
106
+
107
+
108
+ Setup
109
+ =====
110
+
111
+ #. Install:
112
+
113
+ .. code-block:: shell
114
+
115
+ pip install sphinx-scrapy
116
+
117
+ #. Add to your ``conf.py``:
118
+
119
+ .. code-block:: python
120
+
121
+ extensions = [
122
+ "sphinx_scrapy",
123
+ ]
124
+
125
+
126
+ Release notes
127
+ =============
128
+
129
+ See `Release notes`_ for a list of releases and their changes.
130
+
131
+ .. _Release notes: https://github.com/scrapy/sphinx-scrapy/blob/main/CHANGES.rst
@@ -0,0 +1,102 @@
1
+ =============
2
+ sphinx-scrapy
3
+ =============
4
+
5
+ |version| |python_version|
6
+
7
+ .. |version| image:: https://img.shields.io/pypi/v/sphinx-scrapy.svg
8
+ :target: https://pypi.org/pypi/sphinx-scrapy
9
+ :alt: PyPI version
10
+
11
+ .. |python_version| image:: https://img.shields.io/pypi/pyversions/sphinx-scrapy.svg
12
+ :target: https://pypi.org/pypi/sphinx-scrapy
13
+ :alt: Supported Python versions
14
+
15
+ Sphinx_ extension for documentation in the Scrapy_ ecosystem.
16
+
17
+ .. _Sphinx: https://www.sphinx-doc.org/
18
+ .. _Scrapy: https://scrapy.org/
19
+
20
+
21
+ Features
22
+ ========
23
+
24
+ - Automatic configuration of intersphinx_ for Python_ and Scrapy_.
25
+
26
+ Ready-to-use, easy-to-enable configuration for the following packages of
27
+ the Scrapy_ ecosystem is also available:
28
+
29
+ .. _intersphinx: https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
30
+ .. _Python: https://docs.python.org/
31
+
32
+ | `attrs <https://www.attrs.org/en/stable/>`_
33
+ | `cssselect <https://cssselect.readthedocs.io/en/latest>`_
34
+ | `itemloaders <https://itemloaders.readthedocs.io/en/latest/>`_
35
+ | `parsel <https://parsel.readthedocs.io/en/latest/>`_
36
+ | `python-zyte-api <https://python-zyte-api.readthedocs.io/en/stable/>`_
37
+ | `scrapy-poet <https://scrapy-poet.readthedocs.io/en/stable/>`_
38
+ | `tenacity <https://tenacity.readthedocs.io/en/latest>`_
39
+ | `twisted <https://docs.twisted.org/en/stable/>`_ (and `twistedapi <https://docs.twisted.org/en/stable/api/>`_)
40
+ | `w3lib <https://w3lib.readthedocs.io/en/latest/>`_
41
+ | `web-poet <https://web-poet.readthedocs.io/en/stable/>`_
42
+ | `zyte <https://docs.zyte.com>`_
43
+ | `zyte-common-items <https://zyte-common-items.readthedocs.io/en/latest>`_
44
+ | `zyte-spider-templates <https://zyte-spider-templates.readthedocs.io/en/latest>`_
45
+
46
+ To automatically configure intersphinx for any of those packages if
47
+ installed, add to your ``conf.py`` file:
48
+
49
+ .. code-block:: python
50
+
51
+ scrapy_intersphinx_enable_installed = True
52
+
53
+ You can also enable or disable the automatic intersphinx configuration of
54
+ packages manually:
55
+
56
+ .. code-block:: python
57
+
58
+ scrapy_intersphinx_enable = [
59
+ "parsel",
60
+ "w3lib",
61
+ ]
62
+ scrapy_intersphinx_disable = [
63
+ "scrapy",
64
+ ]
65
+
66
+ - Automatic configuration of Sphinx roles of the Scrapy documentation, so
67
+ that you can easily link to Scrapy settings, request metadata keys, signals
68
+ and commands:
69
+
70
+ .. code-block:: rst
71
+
72
+ :setting:`BOT_NAME`
73
+ :setting:`LOG_LEVEL <scrapy:LOG_LEVEL>`
74
+ :reqmeta:`download_slot`
75
+ :signal:`spider_opened`
76
+ :command:`crawl`
77
+
78
+
79
+ Setup
80
+ =====
81
+
82
+ #. Install:
83
+
84
+ .. code-block:: shell
85
+
86
+ pip install sphinx-scrapy
87
+
88
+ #. Add to your ``conf.py``:
89
+
90
+ .. code-block:: python
91
+
92
+ extensions = [
93
+ "sphinx_scrapy",
94
+ ]
95
+
96
+
97
+ Release notes
98
+ =============
99
+
100
+ See `Release notes`_ for a list of releases and their changes.
101
+
102
+ .. _Release notes: https://github.com/scrapy/sphinx-scrapy/blob/main/CHANGES.rst
@@ -0,0 +1,122 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sphinx-scrapy"
7
+ version = "0.1.0"
8
+ description = "Sphinx extension for documentation in the Scrapy ecosystem"
9
+ dependencies = [
10
+ "sphinx",
11
+ ]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Framework :: Scrapy",
15
+ "Intended Audience :: Developers",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Internet :: WWW/HTTP",
25
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ ]
28
+ license = "BSD-3-Clause"
29
+ license-files = ["LICENSE"]
30
+ readme = "README.rst"
31
+ requires-python = ">=3.9"
32
+ authors = [{ name = "Scrapy developers", email = "opensource@zyte.com" }]
33
+ maintainers = [{ name = "Scrapy developers", email = "opensource@zyte.com" }]
34
+
35
+ [project.urls]
36
+ Source = "https://github.com/scrapy/sphinx-scrapy"
37
+ Tracker = "https://github.com/scrapy/sphinx-scrapy/issues"
38
+ "Release notes" = "https://github.com/scrapy/sphinx-scrapy/blob/main/CHANGES.rst"
39
+
40
+ [tool.mypy]
41
+ strict = true
42
+
43
+ [tool.bumpversion]
44
+ current_version = "0.1.0"
45
+ commit = true
46
+ tag = true
47
+ tag_name = "{new_version}"
48
+
49
+ [[tool.bumpversion.files]]
50
+ filename = "CHANGES.rst"
51
+ search = "\\(unreleased\\)$"
52
+ replace = "({now:%Y-%m-%d})"
53
+ regex = true
54
+
55
+ [tool.ruff.lint]
56
+ extend-select = [
57
+ # flake8-bugbear
58
+ "B",
59
+ # flake8-comprehensions
60
+ "C4",
61
+ # pydocstyle
62
+ "D",
63
+ # flake8-future-annotations
64
+ "FA",
65
+ # flynt
66
+ "FLY",
67
+ # refurb
68
+ "FURB",
69
+ # isort
70
+ "I",
71
+ # flake8-implicit-str-concat
72
+ "ISC",
73
+ # flake8-logging
74
+ "LOG",
75
+ # Perflint
76
+ "PERF",
77
+ # pygrep-hooks
78
+ "PGH",
79
+ # flake8-pie
80
+ "PIE",
81
+ # pylint
82
+ "PL",
83
+ # flake8-pytest-style
84
+ "PT",
85
+ # flake8-use-pathlib
86
+ "PTH",
87
+ # flake8-pyi
88
+ "PYI",
89
+ # flake8-quotes
90
+ "Q",
91
+ # flake8-return
92
+ "RET",
93
+ # flake8-raise
94
+ "RSE",
95
+ # Ruff-specific rules
96
+ "RUF",
97
+ # flake8-bandit
98
+ "S",
99
+ # flake8-simplify
100
+ "SIM",
101
+ # flake8-slots
102
+ "SLOT",
103
+ # flake8-debugger
104
+ "T10",
105
+ # flake8-type-checking
106
+ "TC",
107
+ # flake8-tidy-imports
108
+ "TID",
109
+ # pyupgrade
110
+ "UP",
111
+ # pycodestyle warnings
112
+ "W",
113
+ # flake8-2020
114
+ "YTT",
115
+ ]
116
+ ignore = [
117
+ # No public API to document
118
+ "D",
119
+ ]
120
+
121
+ [tool.ruff.lint.pydocstyle]
122
+ convention = "pep257"
@@ -0,0 +1,100 @@
1
+ from collections.abc import Generator
2
+
3
+ from sphinx.application import Sphinx
4
+ from sphinx.config import Config
5
+
6
+ INTERSPHINX_MAPPING = {
7
+ "attrs": ("https://www.attrs.org/en/stable/", None),
8
+ "cssselect": ("https://cssselect.readthedocs.io/en/latest", None),
9
+ "itemloaders": ("https://itemloaders.readthedocs.io/en/latest/", None),
10
+ "parsel": ("https://parsel.readthedocs.io/en/latest/", None),
11
+ "python": ("https://docs.python.org/3", None),
12
+ "python-zyte-api": ("https://python-zyte-api.readthedocs.io/en/stable", None),
13
+ "scrapy": ("https://docs.scrapy.org/en/latest", None),
14
+ "scrapy-poet": ("https://scrapy-poet.readthedocs.io/en/stable", None),
15
+ "tenacity": ("https://tenacity.readthedocs.io/en/latest", None),
16
+ "twisted": ("https://docs.twisted.org/en/stable/", None),
17
+ "twistedapi": ("https://docs.twisted.org/en/stable/api/", None),
18
+ "w3lib": ("https://w3lib.readthedocs.io/en/latest", None),
19
+ "web-poet": ("https://web-poet.readthedocs.io/en/stable", None),
20
+ "zyte": ("https://docs.zyte.com", None),
21
+ "zyte-common-items": ("https://zyte-common-items.readthedocs.io/en/latest", None),
22
+ "zyte-spider-templates": (
23
+ "https://zyte-spider-templates.readthedocs.io/en/latest",
24
+ None,
25
+ ),
26
+ }
27
+
28
+ # By default, interphinx entries are configured if a same-bame module is
29
+ # installed. Here you can set True to always configure the entry unless
30
+ # explicitly disabled, False to never configure the entry unless explicitly
31
+ # requested, or a string to use as the package name to check for.
32
+ PACKAGE_OVERRIDES = {
33
+ "python": True,
34
+ "python-zyte-api": "zyte-api",
35
+ "scrapy": True,
36
+ "twistedapi": "twisted",
37
+ "zyte": False,
38
+ }
39
+
40
+
41
+ def setup(app: Sphinx) -> None:
42
+ app.add_config_value(
43
+ "scrapy_intersphinx_enable", [], "env", types=frozenset({list})
44
+ )
45
+ app.add_config_value(
46
+ "scrapy_intersphinx_enable_installed", False, "env", types=frozenset({bool})
47
+ )
48
+ app.add_config_value(
49
+ "scrapy_intersphinx_disable", [], "env", types=frozenset({list})
50
+ )
51
+
52
+ app.setup_extension("sphinx.ext.intersphinx")
53
+ app.connect("config-inited", update_config)
54
+
55
+ # https://github.com/scrapy/scrapy/blob/dba37674e6eaa6c2030c8eb35ebf8127cd488062/docs/_ext/scrapydocs.py#L90C16-L110C6
56
+ for crossref_type in ("setting", "signal", "command", "reqmeta"):
57
+ app.add_crossref_type(
58
+ directivename=crossref_type,
59
+ rolename=crossref_type,
60
+ )
61
+
62
+
63
+ def update_config(app: Sphinx, config: Config) -> None:
64
+ known = set(INTERSPHINX_MAPPING)
65
+ default = {k for k in INTERSPHINX_MAPPING if PACKAGE_OVERRIDES.get(k) is True}
66
+ disabled = set(config.scrapy_intersphinx_disable)
67
+ non_disabled = known - disabled
68
+ requested = set(config.scrapy_intersphinx_enable)
69
+ to_configure = (
70
+ requested
71
+ | (default - disabled)
72
+ | (
73
+ set(installed(non_disabled - requested - default))
74
+ if config.scrapy_intersphinx_enable_installed
75
+ else set()
76
+ )
77
+ )
78
+ for k in to_configure:
79
+ config.intersphinx_mapping[k] = INTERSPHINX_MAPPING[k]
80
+
81
+
82
+ def installed(names: set[str]) -> Generator[str, None, None]:
83
+ checked: dict[str, bool] = {}
84
+ for name in names:
85
+ if name in PACKAGE_OVERRIDES:
86
+ package = PACKAGE_OVERRIDES[name]
87
+ if package is False:
88
+ continue
89
+ if name in checked:
90
+ if checked[name]:
91
+ yield name
92
+ continue
93
+ module_name = name.replace("-", "_")
94
+ try:
95
+ __import__(module_name)
96
+ except ImportError:
97
+ checked[name] = False
98
+ continue
99
+ checked[name] = True
100
+ yield name