Enforced absolute targets for :doc: in docs.

This commit is contained in:
Adam Johnson 2025-06-27 14:33:40 +01:00
parent a388287692
commit 50b797aa1f
7 changed files with 181 additions and 156 deletions

View file

@ -13,7 +13,7 @@ from sphinx import addnodes
from sphinx import version_info as sphinx_version
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives.code import CodeBlock
from sphinx.domains.std import Cmdoption
from sphinx.domains.std import Cmdoption, StandardDomain
from sphinx.errors import ExtensionError
from sphinx.util import logging
from sphinx.util.console import bold
@ -69,6 +69,30 @@ def setup(app):
app.add_directive("console", ConsoleDirective)
app.connect("html-page-context", html_page_context_hook)
app.add_role("default-role-error", default_role_error)
# Wrap StandardDomain._resolve_doc_xref to warn about :doc: being used with
# relative targets.
orig_resolve_doc_xref = StandardDomain._resolve_doc_xref
def _resolve_doc_xref(
self, env, fromdocname, builder, typ, target, node, contnode
) -> nodes.reference | None:
if not node["reftarget"].startswith("/") and not node["reftarget"].startswith(
"python:"
):
logger.warning(
":doc: used with relative target: %r",
node["reftarget"],
location=node,
type="ref",
subtype=node["reftype"],
)
return orig_resolve_doc_xref(
self, env, fromdocname, builder, typ, target, node, contnode
)
StandardDomain._resolve_doc_xref = _resolve_doc_xref
return {"parallel_read_safe": True}

View file

@ -25,4 +25,4 @@ Indices, glossary and tables
* :ref:`genindex`
* :ref:`modindex`
* :doc:`glossary`
* :doc:`/glossary`

View file

@ -29,8 +29,8 @@ You should also consider how you will handle :doc:`static files
:doc:`error reporting</howto/error-reporting>`.
Finally, before you deploy your application to production, you should run
through our :doc:`deployment checklist<checklist>` to ensure that your
configurations are suitable.
through our :doc:`deployment checklist</howto/deployment/checklist>` to ensure
that your configurations are suitable.
.. _WSGI: https://wsgi.readthedocs.io/en/latest/
.. _ASGI: https://asgi.readthedocs.io/en/latest/

View file

@ -12,34 +12,34 @@ First steps
Are you new to Django or to programming? This is the place to start!
* **From scratch:**
:doc:`Overview <intro/overview>` |
:doc:`Installation <intro/install>`
:doc:`Overview </intro/overview>` |
:doc:`Installation </intro/install>`
* **Tutorial:**
:doc:`Part 1: Requests and responses <intro/tutorial01>` |
:doc:`Part 2: Models and the admin site <intro/tutorial02>` |
:doc:`Part 3: Views and templates <intro/tutorial03>` |
:doc:`Part 4: Forms and generic views <intro/tutorial04>` |
:doc:`Part 5: Testing <intro/tutorial05>` |
:doc:`Part 6: Static files <intro/tutorial06>` |
:doc:`Part 7: Customizing the admin site <intro/tutorial07>` |
:doc:`Part 8: Adding third-party packages <intro/tutorial08>`
:doc:`Part 1: Requests and responses </intro/tutorial01>` |
:doc:`Part 2: Models and the admin site </intro/tutorial02>` |
:doc:`Part 3: Views and templates </intro/tutorial03>` |
:doc:`Part 4: Forms and generic views </intro/tutorial04>` |
:doc:`Part 5: Testing </intro/tutorial05>` |
:doc:`Part 6: Static files </intro/tutorial06>` |
:doc:`Part 7: Customizing the admin site </intro/tutorial07>` |
:doc:`Part 8: Adding third-party packages </intro/tutorial08>`
* **Advanced Tutorials:**
:doc:`How to write reusable apps <intro/reusable-apps>` |
:doc:`Writing your first contribution to Django <intro/contributing>`
:doc:`How to write reusable apps </intro/reusable-apps>` |
:doc:`Writing your first contribution to Django </intro/contributing>`
Getting help
============
Having trouble? We'd like to help!
* Try the :doc:`FAQ <faq/index>` -- it's got answers to many common questions.
* Try the :doc:`FAQ </faq/index>` -- it's got answers to many common questions.
* Looking for specific information? Try the :ref:`genindex`, :ref:`modindex` or
the :doc:`detailed table of contents <contents>`.
the :doc:`detailed table of contents </contents>`.
* Not found anything? See :doc:`faq/help` for information on getting support
* Not found anything? See :doc:`/faq/help` for information on getting support
and asking questions to the community.
* Report bugs with Django in our `ticket tracker`_.
@ -74,46 +74,46 @@ Django provides an abstraction layer (the "models") for structuring and
manipulating the data of your web application. Learn more about it below:
* **Models:**
:doc:`Introduction to models <topics/db/models>` |
:doc:`Field types <ref/models/fields>` |
:doc:`Indexes <ref/models/indexes>` |
:doc:`Meta options <ref/models/options>` |
:doc:`Model class <ref/models/class>`
:doc:`Introduction to models </topics/db/models>` |
:doc:`Field types </ref/models/fields>` |
:doc:`Indexes </ref/models/indexes>` |
:doc:`Meta options </ref/models/options>` |
:doc:`Model class </ref/models/class>`
* **QuerySets:**
:doc:`Making queries <topics/db/queries>` |
:doc:`QuerySet method reference <ref/models/querysets>` |
:doc:`Lookup expressions <ref/models/lookups>`
:doc:`Making queries </topics/db/queries>` |
:doc:`QuerySet method reference </ref/models/querysets>` |
:doc:`Lookup expressions </ref/models/lookups>`
* **Model instances:**
:doc:`Instance methods <ref/models/instances>` |
:doc:`Accessing related objects <ref/models/relations>`
:doc:`Instance methods </ref/models/instances>` |
:doc:`Accessing related objects </ref/models/relations>`
* **Migrations:**
:doc:`Introduction to Migrations<topics/migrations>` |
:doc:`Operations reference <ref/migration-operations>` |
:doc:`SchemaEditor <ref/schema-editor>` |
:doc:`Writing migrations <howto/writing-migrations>`
:doc:`Introduction to Migrations</topics/migrations>` |
:doc:`Operations reference </ref/migration-operations>` |
:doc:`SchemaEditor </ref/schema-editor>` |
:doc:`Writing migrations </howto/writing-migrations>`
* **Advanced:**
:doc:`Managers <topics/db/managers>` |
:doc:`Raw SQL <topics/db/sql>` |
:doc:`Transactions <topics/db/transactions>` |
:doc:`Aggregation <topics/db/aggregation>` |
:doc:`Search <topics/db/search>` |
:doc:`Custom fields <howto/custom-model-fields>` |
:doc:`Multiple databases <topics/db/multi-db>` |
:doc:`Custom lookups <howto/custom-lookups>` |
:doc:`Query Expressions <ref/models/expressions>` |
:doc:`Conditional Expressions <ref/models/conditional-expressions>` |
:doc:`Database Functions <ref/models/database-functions>`
:doc:`Managers </topics/db/managers>` |
:doc:`Raw SQL </topics/db/sql>` |
:doc:`Transactions </topics/db/transactions>` |
:doc:`Aggregation </topics/db/aggregation>` |
:doc:`Search </topics/db/search>` |
:doc:`Custom fields </howto/custom-model-fields>` |
:doc:`Multiple databases </topics/db/multi-db>` |
:doc:`Custom lookups </howto/custom-lookups>` |
:doc:`Query Expressions </ref/models/expressions>` |
:doc:`Conditional Expressions </ref/models/conditional-expressions>` |
:doc:`Database Functions </ref/models/database-functions>`
* **Other:**
:doc:`Supported databases <ref/databases>` |
:doc:`Legacy databases <howto/legacy-databases>` |
:doc:`Providing initial data <howto/initial-data>` |
:doc:`Optimize database access <topics/db/optimization>` |
:doc:`PostgreSQL specific features <ref/contrib/postgres/index>`
:doc:`Supported databases </ref/databases>` |
:doc:`Legacy databases </howto/legacy-databases>` |
:doc:`Providing initial data </howto/initial-data>` |
:doc:`Optimize database access </topics/db/optimization>` |
:doc:`PostgreSQL specific features </ref/contrib/postgres/index>`
The view layer
==============
@ -123,39 +123,39 @@ processing a user's request and for returning the response. Find all you need
to know about views via the links below:
* **The basics:**
:doc:`URLconfs <topics/http/urls>` |
:doc:`View functions <topics/http/views>` |
:doc:`Shortcuts <topics/http/shortcuts>` |
:doc:`Decorators <topics/http/decorators>` |
:doc:`Asynchronous Support <topics/async>`
:doc:`URLconfs </topics/http/urls>` |
:doc:`View functions </topics/http/views>` |
:doc:`Shortcuts </topics/http/shortcuts>` |
:doc:`Decorators </topics/http/decorators>` |
:doc:`Asynchronous Support </topics/async>`
* **Reference:**
:doc:`Built-in Views <ref/views>` |
:doc:`Request/response objects <ref/request-response>` |
:doc:`TemplateResponse objects <ref/template-response>`
:doc:`Built-in Views </ref/views>` |
:doc:`Request/response objects </ref/request-response>` |
:doc:`TemplateResponse objects </ref/template-response>`
* **File uploads:**
:doc:`Overview <topics/http/file-uploads>` |
:doc:`File objects <ref/files/file>` |
:doc:`Storage API <ref/files/storage>` |
:doc:`Managing files <topics/files>` |
:doc:`Custom storage <howto/custom-file-storage>`
:doc:`Overview </topics/http/file-uploads>` |
:doc:`File objects </ref/files/file>` |
:doc:`Storage API </ref/files/storage>` |
:doc:`Managing files </topics/files>` |
:doc:`Custom storage </howto/custom-file-storage>`
* **Class-based views:**
:doc:`Overview <topics/class-based-views/index>` |
:doc:`Built-in display views <topics/class-based-views/generic-display>` |
:doc:`Built-in editing views <topics/class-based-views/generic-editing>` |
:doc:`Using mixins <topics/class-based-views/mixins>` |
:doc:`API reference <ref/class-based-views/index>` |
:doc:`Flattened index<ref/class-based-views/flattened-index>`
:doc:`Overview </topics/class-based-views/index>` |
:doc:`Built-in display views </topics/class-based-views/generic-display>` |
:doc:`Built-in editing views </topics/class-based-views/generic-editing>` |
:doc:`Using mixins </topics/class-based-views/mixins>` |
:doc:`API reference </ref/class-based-views/index>` |
:doc:`Flattened index </ref/class-based-views/flattened-index>`
* **Advanced:**
:doc:`Generating CSV <howto/outputting-csv>` |
:doc:`Generating PDF <howto/outputting-pdf>`
:doc:`Generating CSV </howto/outputting-csv>` |
:doc:`Generating PDF </howto/outputting-pdf>`
* **Middleware:**
:doc:`Overview <topics/http/middleware>` |
:doc:`Built-in middleware classes <ref/middleware>`
:doc:`Overview </topics/http/middleware>` |
:doc:`Built-in middleware classes </ref/middleware>`
The template layer
==================
@ -165,17 +165,17 @@ information to be presented to the user. Learn how this syntax can be used by
designers and how it can be extended by programmers:
* **The basics:**
:doc:`Overview <topics/templates>`
:doc:`Overview </topics/templates>`
* **For designers:**
:doc:`Language overview <ref/templates/language>` |
:doc:`Built-in tags and filters <ref/templates/builtins>` |
:doc:`Humanization <ref/contrib/humanize>`
:doc:`Language overview </ref/templates/language>` |
:doc:`Built-in tags and filters </ref/templates/builtins>` |
:doc:`Humanization </ref/contrib/humanize>`
* **For programmers:**
:doc:`Template API <ref/templates/api>` |
:doc:`Custom tags and filters <howto/custom-template-tags>` |
:doc:`Custom template backend <howto/custom-template-backend>`
:doc:`Template API </ref/templates/api>` |
:doc:`Custom tags and filters </howto/custom-template-tags>` |
:doc:`Custom template backend </howto/custom-template-backend>`
Forms
=====
@ -184,16 +184,16 @@ Django provides a rich framework to facilitate the creation of forms and the
manipulation of form data.
* **The basics:**
:doc:`Overview <topics/forms/index>` |
:doc:`Form API <ref/forms/api>` |
:doc:`Built-in fields <ref/forms/fields>` |
:doc:`Built-in widgets <ref/forms/widgets>`
:doc:`Overview </topics/forms/index>` |
:doc:`Form API </ref/forms/api>` |
:doc:`Built-in fields </ref/forms/fields>` |
:doc:`Built-in widgets </ref/forms/widgets>`
* **Advanced:**
:doc:`Forms for models <topics/forms/modelforms>` |
:doc:`Integrating media <topics/forms/media>` |
:doc:`Formsets <topics/forms/formsets>` |
:doc:`Customizing validation <ref/forms/validation>`
:doc:`Forms for models </topics/forms/modelforms>` |
:doc:`Integrating media </topics/forms/media>` |
:doc:`Formsets </topics/forms/formsets>` |
:doc:`Customizing validation </ref/forms/validation>`
The development process
=======================
@ -202,32 +202,32 @@ Learn about the various components and tools to help you in the development and
testing of Django applications:
* **Settings:**
:doc:`Overview <topics/settings>` |
:doc:`Full list of settings <ref/settings>`
:doc:`Overview </topics/settings>` |
:doc:`Full list of settings </ref/settings>`
* **Applications:**
:doc:`Overview <ref/applications>`
:doc:`Overview </ref/applications>`
* **Exceptions:**
:doc:`Overview <ref/exceptions>`
:doc:`Overview </ref/exceptions>`
* **django-admin and manage.py:**
:doc:`Overview <ref/django-admin>` |
:doc:`Adding custom commands <howto/custom-management-commands>`
:doc:`Overview </ref/django-admin>` |
:doc:`Adding custom commands </howto/custom-management-commands>`
* **Testing:**
:doc:`Introduction <topics/testing/index>` |
:doc:`Writing and running tests <topics/testing/overview>` |
:doc:`Included testing tools <topics/testing/tools>` |
:doc:`Advanced topics <topics/testing/advanced>`
:doc:`Introduction </topics/testing/index>` |
:doc:`Writing and running tests </topics/testing/overview>` |
:doc:`Included testing tools </topics/testing/tools>` |
:doc:`Advanced topics </topics/testing/advanced>`
* **Deployment:**
:doc:`Overview <howto/deployment/index>` |
:doc:`WSGI servers <howto/deployment/wsgi/index>` |
:doc:`ASGI servers <howto/deployment/asgi/index>` |
:doc:`Deploying static files <howto/static-files/deployment>` |
:doc:`Tracking code errors by email <howto/error-reporting>` |
:doc:`Deployment checklist <howto/deployment/checklist>`
:doc:`Overview </howto/deployment/index>` |
:doc:`WSGI servers </howto/deployment/wsgi/index>` |
:doc:`ASGI servers </howto/deployment/asgi/index>` |
:doc:`Deploying static files </howto/static-files/deployment>` |
:doc:`Tracking code errors by email </howto/error-reporting>` |
:doc:`Deployment checklist </howto/deployment/checklist>`
The admin
=========
@ -235,9 +235,9 @@ The admin
Find all you need to know about the automated admin interface, one of Django's
most popular features:
* :doc:`Admin site <ref/contrib/admin/index>`
* :doc:`Admin actions <ref/contrib/admin/actions>`
* :doc:`Admin documentation generator<ref/contrib/admin/admindocs>`
* :doc:`Admin site </ref/contrib/admin/index>`
* :doc:`Admin actions </ref/contrib/admin/actions>`
* :doc:`Admin documentation generator </ref/contrib/admin/admindocs>`
Security
========
@ -245,11 +245,11 @@ Security
Security is a topic of paramount importance in the development of web
applications and Django provides multiple protection tools and mechanisms:
* :doc:`Security overview <topics/security>`
* :doc:`Disclosed security issues in Django <releases/security>`
* :doc:`Clickjacking protection <ref/clickjacking>`
* :doc:`Cross Site Request Forgery protection <ref/csrf>`
* :doc:`Cryptographic signing <topics/signing>`
* :doc:`Security overview </topics/security>`
* :doc:`Disclosed security issues in Django </releases/security>`
* :doc:`Clickjacking protection </ref/clickjacking>`
* :doc:`Cross Site Request Forgery protection </ref/csrf>`
* :doc:`Cryptographic signing </topics/signing>`
* :ref:`Security Middleware <security-middleware>`
Internationalization and localization
@ -259,10 +259,10 @@ Django offers a robust internationalization and localization framework to
assist you in the development of applications for multiple languages and world
regions:
* :doc:`Overview <topics/i18n/index>` |
:doc:`Internationalization <topics/i18n/translation>` |
* :doc:`Overview </topics/i18n/index>` |
:doc:`Internationalization </topics/i18n/translation>` |
:ref:`Localization <how-to-create-language-files>` |
:doc:`Localized web UI formatting and form input <topics/i18n/formatting>`
:doc:`Localized web UI formatting and form input </topics/i18n/formatting>`
* :doc:`Time zones </topics/i18n/timezones>`
Performance and optimization
@ -271,12 +271,12 @@ Performance and optimization
There are a variety of techniques and tools that can help get your code running
more efficiently - faster, and using fewer system resources.
* :doc:`Performance and optimization overview <topics/performance>`
* :doc:`Performance and optimization overview </topics/performance>`
Geographic framework
====================
:doc:`GeoDjango <ref/contrib/gis/index>` intends to be a world-class geographic
:doc:`GeoDjango </ref/contrib/gis/index>` intends to be a world-class geographic
web framework. Its goal is to make it as easy as possible to build GIS web
applications and harness the power of spatially enabled data.
@ -287,36 +287,36 @@ Django offers multiple tools commonly needed in the development of web
applications:
* **Authentication:**
:doc:`Overview <topics/auth/index>` |
:doc:`Using the authentication system <topics/auth/default>` |
:doc:`Password management <topics/auth/passwords>` |
:doc:`Customizing authentication <topics/auth/customizing>` |
:doc:`API Reference <ref/contrib/auth>`
* :doc:`Caching <topics/cache>`
* :doc:`Logging <topics/logging>`
* :doc:`Sending emails <topics/email>`
* :doc:`Syndication feeds (RSS/Atom) <ref/contrib/syndication>`
* :doc:`Pagination <topics/pagination>`
* :doc:`Messages framework <ref/contrib/messages>`
* :doc:`Serialization <topics/serialization>`
* :doc:`Sessions <topics/http/sessions>`
* :doc:`Sitemaps <ref/contrib/sitemaps>`
* :doc:`Static files management <ref/contrib/staticfiles>`
* :doc:`Data validation <ref/validators>`
:doc:`Overview </topics/auth/index>` |
:doc:`Using the authentication system </topics/auth/default>` |
:doc:`Password management </topics/auth/passwords>` |
:doc:`Customizing authentication </topics/auth/customizing>` |
:doc:`API Reference </ref/contrib/auth>`
* :doc:`Caching </topics/cache>`
* :doc:`Logging </topics/logging>`
* :doc:`Sending emails </topics/email>`
* :doc:`Syndication feeds (RSS/Atom) </ref/contrib/syndication>`
* :doc:`Pagination </topics/pagination>`
* :doc:`Messages framework </ref/contrib/messages>`
* :doc:`Serialization </topics/serialization>`
* :doc:`Sessions </topics/http/sessions>`
* :doc:`Sitemaps </ref/contrib/sitemaps>`
* :doc:`Static files management </ref/contrib/staticfiles>`
* :doc:`Data validation </ref/validators>`
Other core functionalities
==========================
Learn about some other core functionalities of the Django framework:
* :doc:`Conditional content processing <topics/conditional-view-processing>`
* :doc:`Content types and generic relations <ref/contrib/contenttypes>`
* :doc:`Flatpages <ref/contrib/flatpages>`
* :doc:`Redirects <ref/contrib/redirects>`
* :doc:`Signals <topics/signals>`
* :doc:`System check framework <topics/checks>`
* :doc:`The sites framework <ref/contrib/sites>`
* :doc:`Unicode in Django <ref/unicode>`
* :doc:`Conditional content processing </topics/conditional-view-processing>`
* :doc:`Content types and generic relations </ref/contrib/contenttypes>`
* :doc:`Flatpages </ref/contrib/flatpages>`
* :doc:`Redirects </ref/contrib/redirects>`
* :doc:`Signals </topics/signals>`
* :doc:`System check framework </topics/checks>`
* :doc:`The sites framework </ref/contrib/sites>`
* :doc:`Unicode in Django </ref/unicode>`
The Django open-source project
==============================
@ -325,23 +325,23 @@ Learn about the development process for the Django project itself and about how
you can contribute:
* **Community:**
:doc:`Contributing to Django <internals/contributing/index>` |
:doc:`The release process <internals/release-process>` |
:doc:`Team organization <internals/organization>` |
:doc:`The Django source code repository <internals/git>` |
:doc:`Security policies <internals/security>` |
:doc:`Mailing lists and Forum<internals/mailing-lists>`
:doc:`Contributing to Django </internals/contributing/index>` |
:doc:`The release process </internals/release-process>` |
:doc:`Team organization </internals/organization>` |
:doc:`The Django source code repository </internals/git>` |
:doc:`Security policies </internals/security>` |
:doc:`Mailing lists and Forum </internals/mailing-lists>`
* **Design philosophies:**
:doc:`Overview <misc/design-philosophies>`
:doc:`Overview </misc/design-philosophies>`
* **Documentation:**
:doc:`About this documentation <internals/contributing/writing-documentation>`
:doc:`About this documentation </internals/contributing/writing-documentation>`
* **Third-party distributions:**
:doc:`Overview <misc/distributions>`
:doc:`Overview </misc/distributions>`
* **Django over time:**
:doc:`API stability <misc/api-stability>` |
:doc:`Release notes and upgrading instructions <releases/index>` |
:doc:`Deprecation Timeline <internals/deprecation>`
:doc:`API stability </misc/api-stability>` |
:doc:`Release notes and upgrading instructions </releases/index>` |
:doc:`Deprecation Timeline </internals/deprecation>`

View file

@ -55,7 +55,7 @@ particular:
as they are filed.
To understand the lifecycle of your ticket once you have created it, refer to
:doc:`triaging-tickets`.
:doc:`/internals/contributing/triaging-tickets`.
Reporting user interface bugs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -4,7 +4,8 @@ Committing code
This section is addressed to the mergers and to anyone interested in knowing
how code gets committed into Django. If you're a community member who wants to
contribute code to Django, look at :doc:`writing-code/working-with-git` instead.
contribute code to Django, look at
:doc:`/internals/contributing/writing-code/working-with-git` instead.
.. _handling-pull-requests:

View file

@ -61,8 +61,8 @@ the date, time and numbers formatting particularities of your locale. See
The format files aren't managed by the use of Transifex. To change them, you
must:
* :doc:`Create a pull request<writing-code/submitting-patches>` against the
Django Git ``main`` branch, as for any code change.
* :doc:`Create a pull request </internals/contributing/writing-code/submitting-patches>`
against the Django Git ``main`` branch, as for any code change.
* Open a ticket in Django's ticket system, set its ``Component`` field to
``Translations``, set the "has patch" flag, and include the link to the pull