{"title":"编写文档","version":"5.2","locale":"zh-hans","docname":"internals/contributing/writing-documentation","url":"/zh-hans/5.2/internals/contributing/writing-documentation/","canonical":"https://djangodocs.dev/zh-hans/5.2/internals/contributing/writing-documentation/","summary":"我们非常重视文档的一致性和可读性。毕竟，Django 是在新闻环境中创建的！因此，我们像对待我们的代码一样对待我们的文档：我们努力在尽可能多的时间里改进它。 一般来说，文档会在以下两种情况时更新： 一般改进：通过更清晰的书写和更多示例，更正、修复文档错误，更好的解释功能。 新特性：自上一个版本发布后，添加到框架中的功能文档。…","html":"<h1>编写文档<a class=\"heading-anchor\" href=\"#writing-documentation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>我们非常重视文档的一致性和可读性。毕竟，Django 是在新闻环境中创建的！因此，我们像对待我们的代码一样对待我们的文档：我们努力在尽可能多的时间里改进它。</p>\n<p>一般来说，文档会在以下两种情况时更新：</p>\n<ul class=\"simple\">\n<li><p>一般改进：通过更清晰的书写和更多示例，更正、修复文档错误，更好的解释功能。</p></li>\n<li><p>新特性：自上一个版本发布后，添加到框架中的功能文档。</p></li>\n</ul>\n<p>本节介绍文档作者如何以最有用和最不容易出错的方式修改文档。</p>\n<section id=\"the-django-documentation-process\">\n<h2>Django 文档编写流程<a class=\"heading-anchor\" href=\"#the-django-documentation-process\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>尽管 Django 的文档旨在以 HTML 形式在 <a class=\"reference external\" href=\"https://docs.djangoproject.com/\">https://docs.djangoproject.com/</a> 上阅读，但我们将其编辑为一组纯文本文件，使用 reStructuredText 标记语言编写，以实现最大的灵活性。</p>\n<p>我们从存储库的开发版本中工作，因为它包含了最新的文档，就像它包含了最新的代码一样。</p>\n<p>我们还会根据合并者的判断，将文档修复和改进内容反向移植到上一个发布分支。这是因为让上一个版本的文档保持最新和正确是有好处的（参见 <a class=\"reference internal\" href=\"/zh-hans/5.2/intro/whatsnext/#differences-between-doc-versions\"><span class=\"std std-ref\">版本之间的差异</span></a>）。</p>\n<p>Django  的文档使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/\">Sphinx</a> 文档系统——基于 <a class=\"reference external\" href=\"https://docutils.sourceforge.io/\">docutils</a>。基本思想是将轻量格式话的纯文本转化为 HTML，PDF 或其它任意输出格式。</p>\n<p>Sphinx 包括一个 <code class=\"docutils literal notranslate\"><span class=\"pre\">sphinx-build</span></code> 命令，用于将 reStructuredText 转换为其他格式，例如 HTML 和 PDF。这个命令是可配置的，但 Django 文档包括一个 <code class=\"docutils literal notranslate\"><span class=\"pre\">Makefile</span></code>，提供了一个更简短的 <code class=\"docutils literal notranslate\"><span class=\"pre\">make</span> <span class=\"pre\">html</span></code> 命令。</p>\n</section>\n<section id=\"how-the-documentation-is-organized\">\n<h2>文档是如何组成<a class=\"heading-anchor\" href=\"#how-the-documentation-is-organized\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>文档被分为以下几个类别：</p>\n<ul>\n<li><p><a class=\"reference internal\" href=\"/zh-hans/5.2/intro/\"><span class=\"doc\">教程</span></a> 通过几步手把手的教学帮助读者创建一个小玩意。</p>\n<p>教程的目的是帮助读者尽可能早地实现一些有用的东西，以便给他们带来信心。</p>\n<p>解释我们正在解决的问题的性质，以便读者理解我们试图实现什么。不必从事物如何工作的解释开始 - 重要的是读者做什么，而不是你解释什么。在完成操作后回顾并解释可以是有帮助的。</p>\n</li>\n<li><p><a class=\"reference internal\" href=\"/zh-hans/5.2/topics/\"><span class=\"doc\">主题指引</span></a> 旨在在一个较高的层次介绍一个原则或主题。</p>\n<p>链接至参考资料而不要重复它。使用示例时，不要不情愿解释对您而言非常基本的事物——它对别人而言可能需要解释。</p>\n<p>提供背景信息有助于新人将主题和他们已知的东西联系起来。</p>\n</li>\n<li><p><a class=\"reference internal\" href=\"/zh-hans/5.2/ref/\"><span class=\"doc\">参考指南</span></a> 包含 API 的技术参考。它们描述了 Django 内部机制的运作方式，并指导如何使用它。</p>\n<p>让参考资料紧紧围绕着主题。假设读者已经理解了所涉及的基本概念，但需要知道或被提醒 Django 是如何做到的。</p>\n<p>参考指南并不是进行一般性解释的地方。如果你发现自己在解释基本概念，你可能想把这些材料移到主题指南中。</p>\n</li>\n<li><p><a class=\"reference internal\" href=\"/zh-hans/5.2/howto/\"><span class=\"doc\">操作指南</span></a> 是带领读者完成关键科目步骤的方法。</p>\n<p>在指南中最重要的是用户想要实现什么。一个指南应该始终以结果为导向，而不是专注于 Django 如何实现所讨论的内部细节。</p>\n<p>这些指南比教程更高级，并假定有一些关于 Django 如何工作的知识。假设读者已经学习了教程，并且毫不犹豫地让读者回到相应的教程，而不是重复同样的材料。</p>\n</li>\n</ul>\n</section>\n<section id=\"how-to-start-contributing-documentation\">\n<h2>如何开始贡献文档<a class=\"heading-anchor\" href=\"#how-to-start-contributing-documentation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"clone-the-django-repository-to-your-local-machine\">\n<h3>克隆 Django 存储库到您的本地计算机<a class=\"heading-anchor\" href=\"#clone-the-django-repository-to-your-local-machine\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>如果你想开始为我们的文档做贡献，可以从源代码仓库获取 Django 的开发版本（参见：<a class=\"reference internal\" href=\"/zh-hans/5.2/topics/install/#installing-development-version\"><span class=\"std std-ref\">安装开发版本</span></a>）：</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git<span class=\"w\"> </span>clone<span class=\"w\"> </span>https://github.com/django/django.git\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> git clone https://github.com/django/django.git\n</code></pre></div></div></div>\n<p>如果你计划提交这些更改，你可能会发现创建 Django 仓库的一个分支并克隆这个分支会很有用。</p>\n</section>\n<section id=\"set-up-a-virtual-environment-and-install-dependencies\">\n<h3>建立一个虚拟环境并安装依赖项<a class=\"heading-anchor\" href=\"#set-up-a-virtual-environment-and-install-dependencies\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>创建并激活一个虚拟环境，然后安装依赖项：</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>python<span class=\"w\"> </span>-m<span class=\"w\"> </span>venv<span class=\"w\"> </span>.venv\n$<span class=\"w\"> </span><span class=\"nb\">source</span><span class=\"w\"> </span>.venv/bin/activate\n$<span class=\"w\"> </span>python<span class=\"w\"> </span>-m<span class=\"w\"> </span>pip<span class=\"w\"> </span>install<span class=\"w\"> </span>-r<span class=\"w\"> </span>docs/requirements.txt\n</code></pre></div>\n</section>\n<section id=\"build-the-documentation-locally\">\n<h3>在本地构建文档<a class=\"heading-anchor\" href=\"#build-the-documentation-locally\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>我们可以从 <code class=\"docutils literal notranslate\"><span class=\"pre\">docs</span></code> 目录生成 HTML 输出：</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-1-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span><span class=\"nb\">cd</span><span class=\"w\"> </span>docs\n<span class=\"gp\">$ </span>make<span class=\"w\"> </span>html\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-1-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> <span class=\"k\">cd</span> docs\n<span class=\"gp\">...\\&gt;</span> make.bat html\n</code></pre></div></div></div>\n<p>你在本地构建的文档可以在 <code class=\"docutils literal notranslate\"><span class=\"pre\">_build/html/index.html</span></code> 中访问，并且可以在任何网页浏览器中查看，尽管它的主题与 <a class=\"reference external\" href=\"https://docs.djangoproject.com/\">docs.djangoproject.com</a> 上的文档不同。这没关系！如果你的更改在本地看起来不错，它们在网站上也会看起来不错。</p>\n</section>\n<section id=\"making-edits-to-the-documentation\">\n<h3>对文档进行编辑<a class=\"heading-anchor\" href=\"#making-edits-to-the-documentation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>源文件是位于 <code class=\"docutils literal notranslate\"><span class=\"pre\">docs/</span></code> 目录中的 <code class=\"docutils literal notranslate\"><span class=\"pre\">.txt</span></code> 文件。</p>\n<p>这些文件是用 reStructuredText 标记语言编写的。要了解这种标记语言，请参阅 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html#rst-index\" title=\"(in Sphinx v9.1.1)\"><span class=\"xref std std-ref\">reStructuredText 参考手册</span></a>。</p>\n<p>要编辑此页面，例如，我们会编辑文件 <a class=\"extlink-source reference external\" href=\"https://github.com/django/django/blob/stable/5.2.x/docs/internals/contributing/writing-documentation.txt\">docs/internals/contributing/writing-documentation.txt</a>，然后使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">make</span> <span class=\"pre\">html</span></code> 重新构建 HTML。</p>\n</section>\n<section id=\"documentation-quality-checks\">\n<span id=\"documentation-checks\"></span><h3>Documentation quality checks<a class=\"heading-anchor\" href=\"#documentation-quality-checks\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Several checks help maintain Django's documentation quality, including\n<a class=\"reference internal\" href=\"#documentation-spelling-check\"><span class=\"std std-ref\">spelling</span></a> and\n<a class=\"reference internal\" href=\"#documentation-code-block-format-check\"><span class=\"std std-ref\">code block formatting</span></a>.</p>\n<p>These checks are run automatically in CI and must pass before documentation\nchanges can be merged. They can also be run locally with a single command:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-2-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>make<span class=\"w\"> </span>check\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-2-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> make.bat check\n</code></pre></div></div></div>\n<p>This command runs all current checks and will include any new checks added in\nthe future.</p>\n<section id=\"spelling-check\">\n<span id=\"documentation-spelling-check\"></span><h4>拼写检查<a class=\"heading-anchor\" href=\"#spelling-check\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Before you commit your docs, it's a good idea to run the spelling checker.\nYou'll need to install <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/sphinxcontrib-spelling/\">sphinxcontrib-spelling</a> first. Then from the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">docs</span></code> directory, run:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-3-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>make<span class=\"w\"> </span>spelling\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-3-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> make.bat spelling\n</code></pre></div></div></div>\n<p>Wrong words (if any) along with the file and line number where they occur will\nbe saved to <code class=\"docutils literal notranslate\"><span class=\"pre\">_build/spelling/output.txt</span></code>.</p>\n<p>如果你遇到假阳性的情况（错误输出实际上是正确的），请采取以下措施之一：</p>\n<ul class=\"simple\">\n<li><p>用双反引号（``）括起内联代码或品牌/技术名称。</p></li>\n<li><p>查找拼写检查程序发现的同义词。</p></li>\n<li><p>如果，只是如果，你确定你的单词拼写是正确的——将其加入 <code class=\"docutils literal notranslate\"><span class=\"pre\">docs/spelling_wordlist</span></code> （请保持这个列表以字母顺序排列）。</p></li>\n</ul>\n</section>\n<section id=\"code-block-format-check\">\n<span id=\"documentation-code-block-format-check\"></span><h4>Code block format check<a class=\"heading-anchor\" href=\"#code-block-format-check\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>All Python code blocks should be formatted using the <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/blacken-docs/\">blacken-docs</a>\nauto-formatter. This is automatically run by the <a class=\"reference internal\" href=\"/zh-hans/5.2/internals/contributing/writing-code/coding-style/#coding-style-pre-commit\"><span class=\"std std-ref\">pre-commit hook</span></a> if configured.</p>\n<p>The check can also be run manually: provided that <code class=\"docutils literal notranslate\"><span class=\"pre\">blacken-docs</span></code> is installed,\nrun the following command from the <code class=\"docutils literal notranslate\"><span class=\"pre\">docs</span></code> directory:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-4-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>make<span class=\"w\"> </span>black\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-4-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> make.bat black\n</code></pre></div></div></div>\n<p>The formatter will report any issues by printing them to the terminal and will\nreformat code blocks where possible.</p>\n</section>\n</section>\n<section id=\"link-check\">\n<span id=\"documentation-link-check\"></span><h3>链接检查<a class=\"heading-anchor\" href=\"#link-check\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Links in documentation can become broken or changed such that they are no\nlonger the canonical link. Sphinx provides a builder that can check whether the\nlinks in the documentation are working. From the <code class=\"docutils literal notranslate\"><span class=\"pre\">docs</span></code> directory, run:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-5-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>make<span class=\"w\"> </span>linkcheck\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-5-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> make.bat linkcheck\n</code></pre></div></div></div>\n<p>Output is printed to the terminal, but can also be found in\n<code class=\"docutils literal notranslate\"><span class=\"pre\">_build/linkcheck/output.txt</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">_build/linkcheck/output.json</span></code>.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>The execution of the command requires an internet connection and takes\nseveral minutes to complete, because the command tests all the links\nthat are found in the documentation.</p>\n</aside>\n<p>状态为 &quot;working&quot; 的条目是正常的，而状态为 &quot;unchecked&quot; 或 &quot;ignored&quot; 的条目已被跳过，因为它们要么无法检查，要么与配置中的忽略规则匹配。</p>\n<p>状态为 &quot;broken&quot; 的条目需要修复。而状态为 &quot;redirected&quot; 的条目可能需要更新，以指向规范位置，例如，方案已更改为 <code class=\"docutils literal notranslate\"><span class=\"pre\">http://</span></code> → <code class=\"docutils literal notranslate\"><span class=\"pre\">https://</span></code>。在某些情况下，我们不希望更新 &quot;redirected&quot; 链接，例如，重定向始终指向文档的最新或稳定版本，例如，<code class=\"docutils literal notranslate\"><span class=\"pre\">/en/stable/</span></code> → <code class=\"docutils literal notranslate\"><span class=\"pre\">/en/3.2/</span></code>。</p>\n</section>\n</section>\n<section id=\"writing-style\">\n<h2>书写格式<a class=\"heading-anchor\" href=\"#writing-style\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>在提及假设的人时，例如 &quot;一个带有会话 cookie 的用户&quot;，应该使用性别中性的代词 (they/their/them)。而不是：</p>\n<ul class=\"simple\">\n<li><p>he 或 she……使用 they。</p></li>\n<li><p>him 或 her... 使用 them。</p></li>\n<li><p>his 或 her……使用 their。</p></li>\n<li><p>his 或 hers... 使用 theirs。</p></li>\n<li><p>himself 或 herself... 使用 themselves。</p></li>\n</ul>\n<p>尽量避免使用将任务或操作的难度降到最低的词语，如 “easily”、“simply”、“just”、“merely”、“straightforward” 等等。人们的经验可能与你的期望不符，当他们发现某个步骤并不像暗示的那样 “straightforward” 或 “simple” 时，可能会感到沮丧。</p>\n</section>\n<section id=\"commonly-used-terms\">\n<h2>常用术语<a class=\"heading-anchor\" href=\"#commonly-used-terms\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>以下是整个文档中常用术语的一些格式指南：</p>\n<ul class=\"simple\">\n<li><p><strong>Django</strong> -- 当提及该框架时，大写 Django。它仅在 Python 代码中和 djangoproject.com 徽标中使用小写字母。</p></li>\n<li><p><strong>email</strong> -- 无连字符。</p></li>\n<li><p><strong>HTTP</strong> -- 预期的发音是 &quot;Aitch Tee Tee Pee&quot;，因此应该用 &quot;an&quot; 而不是 &quot;a&quot;。</p></li>\n<li><p><strong>MySQL</strong>, <strong>PostgreSQL</strong>, <strong>SQLite</strong></p></li>\n<li><p><strong>SQL</strong> -- 当提及 SQL 时，预期的发音应该是 “Ess Queue Ell” 而不是 “sequel”。因此，在诸如 “Returns an SQL expression” 之类的短语中，“SQL” 前应该使用 “an” 而不是 “a”。</p></li>\n<li><p><strong>Python</strong> -- 当提及该语言时大写。</p></li>\n<li><p><strong>realize</strong>, <strong>customize</strong>, <strong>initialize</strong>, etc. -- 使用美式的 “ize” 后缀，而不是 “ise”。</p></li>\n<li><p><strong>subclass</strong> -- 它是一个没有连字符的单个单词，既作为动词（“子类模型”）又作为名词（“创建子类”）。</p></li>\n<li><p><strong>the web</strong>，<strong>web framework</strong> -- 不需要大写。</p></li>\n<li><p><strong>website</strong> -- 用一个单词表示，不大写。</p></li>\n</ul>\n</section>\n<section id=\"django-specific-terminology\">\n<h2>Django 专用术语<a class=\"heading-anchor\" href=\"#django-specific-terminology\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul class=\"simple\">\n<li><p><strong>model</strong> -- 它不是大写的。</p></li>\n<li><p><strong>template</strong> -- 它不是大写的。</p></li>\n<li><p><strong>URLconf</strong> -- 使用了三个大写字母，在 “conf” 之前没有空格。</p></li>\n<li><p><strong>view</strong> -- 它不是大写的。</p></li>\n</ul>\n</section>\n<section id=\"guidelines-for-restructuredtext-files\">\n<h2>reStructuredText 文件语法指南<a class=\"heading-anchor\" href=\"#guidelines-for-restructuredtext-files\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>这些准则规定了我们的 reST（reStructuredText）文档格式：</p>\n<ul>\n<li><p>在部分标题中，仅将首字母和专有名词大写。</p></li>\n<li><p>将文档以 80 个字符宽换行，除非一个代码例子被分割成两行时可读性明显降低，或者有其他好的理由。</p></li>\n<li><p>在编写和编辑文档时要记住的主要事情是，你能添加的更多语义化标记越多越好。因此：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code>Add <span class=\"s\">``django.contrib.auth``</span> to your <span class=\"s\">``INSTALLED_APPS``</span>...\n</code></pre></div>\n<p>远远不如：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code>Add <span class=\"na\">:mod:</span><span class=\"nv\">`django.contrib.auth`</span> to your <span class=\"na\">:setting:</span><span class=\"nv\">`INSTALLED_APPS`</span>...\n</code></pre></div>\n<p>这是因为 Sphinx 将为后者生成适当的链接，这对读者有很大帮助。</p>\n<p>你可以在目标前加一个 <code class=\"docutils literal notranslate\"><span class=\"pre\">~</span></code> （那是一个波浪号）来获得该路径的 “最后一点”。所以 <code class=\"docutils literal notranslate\"><span class=\"pre\">:mod:`~django.contrib.auth</span></code> 将显示一个标题为 “auth” 的链接。</p>\n</li>\n<li><p>使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#module-sphinx.ext.intersphinx\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">intersphinx</span></code></a> 来引用 Python 和 Sphinx 的文档。</p></li>\n<li><p>在文字块中加入 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">code-block::</span> <span class=\"pre\">&lt;lang&gt;</span></code>，使其得到高亮。更倾向于使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">::</span></code> （两个冒号）来自动突出显示。这样做的好处是，如果代码中包含一些无效的语法，它就不会被高亮显示。例如，添加 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">code-block::</span> <span class=\"pre\">python</span></code>，就可以在无效的语法中强制高亮显示。</p></li>\n<li><p>为了提高可读性，使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">admonition::</span> <span class=\"pre\">Descriptive</span> <span class=\"pre\">title</span></code> 而不是 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">note::</span></code>。尽量少使用这些方框。</p></li>\n<li><p>使用这些标题样式：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"gh\">===</span>\n<span class=\"gh\">One</span>\n<span class=\"gh\">===</span>\n\n<span class=\"gh\">Two</span>\n<span class=\"gh\">===</span>\n\n<span class=\"gh\">Three</span>\n<span class=\"gh\">-----</span>\n\n<span class=\"gh\">Four</span>\n<span class=\"gh\">~~~~</span>\n\n<span class=\"gh\">Five</span>\n<span class=\"gh\">^^^^</span>\n</code></pre></div>\n</li>\n<li><p>Use <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-rfc\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">:rfc:</span></code></a> to reference a Request for Comments (RFC) and\ntry to link to the relevant section if possible. For example, use\n<code class=\"docutils literal notranslate\"><span class=\"pre\">:rfc:`2324#section-2.3.2`</span></code> or\n<code class=\"docutils literal notranslate\"><span class=\"pre\">:rfc:`Custom</span> <span class=\"pre\">link</span> <span class=\"pre\">text</span> <span class=\"pre\">&lt;2324#section-2.3.2&gt;`</span></code>.</p></li>\n<li><p>使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-pep\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">:pep:</span></code></a> 来引用 Python 增强建议（PEP），如果可能的话，尽量链接到相关章节。例如，使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:pep:`20#easter-egg`</span></code> 或 <code class=\"docutils literal notranslate\"><span class=\"pre\">:pep:`Easter</span> <span class=\"pre\">Egg</span> <span class=\"pre\">&lt;20#easter-egg&gt;`</span></code>。</p></li>\n<li><p>使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-mimetype\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">:mimetype:</span></code></a> 来指代一个 MIME 类型，除非在代码示例中引用了这个值。</p></li>\n<li><p>使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/referencing.html#role-envvar\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">:envvar:</span></code></a> 来指代一个环境变量。你可能还需要使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/domains/standard.html#directive-envvar\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-dir docutils literal notranslate\"><span class=\"pre\">...envvar::</span></code></a> 来定义一个对该环境变量的文档的引用。</p></li>\n<li><p>Use <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-cve\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">:cve:</span></code></a> to reference a Common Vulnerabilities and\nExposures (CVE) identifier. For example, use <code class=\"docutils literal notranslate\"><span class=\"pre\">:cve:`2019-14232`</span></code>.</p></li>\n</ul>\n</section>\n<section id=\"django-specific-markup\">\n<h2>Django 特有的标记<a class=\"heading-anchor\" href=\"#django-specific-markup\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>除了 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html#rst-index\" title=\"(in Sphinx v9.1.1)\"><span class=\"xref std std-ref\">Sphinx 的内置标记</span></a>，Django 的文档定义了一些额外的描述单元：</p>\n<ul>\n<li><p>配置：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">setting</span><span class=\"p\">::</span> INSTALLED_APPS\n</code></pre></div>\n<p>为了连接配置，请使用配置 <code class=\"docutils literal notranslate\"><span class=\"pre\">:setting:`INSTALLED_APPS`</span></code>。</p>\n</li>\n<li><p>模板标签：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">templatetag</span><span class=\"p\">::</span> regroup\n</code></pre></div>\n<p>为了链接，请使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:ttag:`regroup`</span></code>。</p>\n</li>\n<li><p>模板过滤器：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">templatefilter</span><span class=\"p\">::</span> linebreaksbr\n</code></pre></div>\n<p>为了链接，请使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:tfilter:`linebreaksbr`</span></code> 。</p>\n</li>\n<li><p>字段查找（例如 <code class=\"docutils literal notranslate\"><span class=\"pre\">Foo.objects.filter(bar__exact=whatever)</span></code>）：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">fieldlookup</span><span class=\"p\">::</span> exact\n</code></pre></div>\n<p>为了链接，请使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:lookup:`exact`</span></code>。</p>\n</li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> 命令：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">django-admin</span><span class=\"p\">::</span> migrate\n</code></pre></div>\n<p>为了链接，请使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:djadmin:`migrate`</span></code>。</p>\n</li>\n<li><p><a href=\"#id1\"><span class=\"problematic\" id=\"id2\">``</span></a>django-admin`命令行选项：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">django-admin-option</span><span class=\"p\">::</span> --traceback\n</code></pre></div>\n<p>为了链接，请使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:option:`command_name</span> <span class=\"pre\">--trackback</span></code> （或者省略 <code class=\"docutils literal notranslate\"><span class=\"pre\">command_name</span></code>，用于所有命令共享的选项，如 <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code>）。</p>\n</li>\n<li><p>Trac 问题的链接（通常用于补丁发布说明）：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"na\">:ticket:</span><span class=\"nv\">`12345`</span>\n</code></pre></div>\n</li>\n</ul>\n<p>Django 的文档使用一个自定义的 <code class=\"docutils literal notranslate\"><span class=\"pre\">console</span></code> 指令，用于记录涉及 <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code>、<code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code>、<code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> 等的命令行实例。在 HTML 文档中，它渲染了一个双选项卡 UI，其中一个选项卡显示 Unix 风格的命令提示符，第二个选项卡显示 Windows 提示符。</p>\n<p>例如，你可以替换这个片段：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code>use this command:\n\n<span class=\"p\">..</span> <span class=\"ow\">code-block</span><span class=\"p\">::</span> console\n\n    $ python manage.py shell\n</code></pre></div>\n<p>用这个替代：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code>use this command:\n\n<span class=\"p\">..</span> <span class=\"ow\">console</span><span class=\"p\">::</span>\n\n    $ python manage.py shell\n</code></pre></div>\n<p>请注意两件事：</p>\n<ul class=\"simple\">\n<li><p>你通常会替换出现的 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">code-block::</span> <span class=\"pre\">console</span></code> 指令。</p></li>\n<li><p>你不需要改变代码例子的实际内容。你仍然假设 Unix-y 环境来编写它（即一个 <code class=\"docutils literal notranslate\"><span class=\"pre\">'$'</span></code> 提示符号，<code class=\"docutils literal notranslate\"><span class=\"pre\">'/'</span></code> 作为文件系统路径组件分隔符等等）。</p></li>\n</ul>\n<p>上面的例子将呈现一个有两个选项卡的代码示例块。第一个将显示：</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>shell\n</code></pre></div>\n<p>与 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">code-block::</span> <span class=\"pre\">console</span></code> 所呈现的内容相比没有变化）。</p>\n<p>第二个将显示：</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py manage.py shell\n</code></pre></div>\n</section>\n<section id=\"documenting-new-features\">\n<span id=\"id3\"></span><h2>记录新功能<a class=\"heading-anchor\" href=\"#documenting-new-features\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>我们对新功能的政策是：</p>\n<blockquote>\n<div><p>所有新功能的文档应以一种明确指出这些功能仅在 Django 开发版本中可用的方式编写。假设文档读者使用的是最新发布版，而不是开发版本。</p>\n</div></blockquote>\n<p>我们首选的标记新特性的方法是在特性的文档前加上。&quot;<code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">versionadded::</span> <span class=\"pre\">X.Y</span></code>&quot;，后面是一个强制性的空行和一个可选的描述（缩进）。</p>\n<p>对 API 进行的一般改进或其他需要强调的更改应使用 &quot;<code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">versionchanged::</span> <span class=\"pre\">X.Y</span></code>&quot; 指令（格式与上面提到的 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionadded</span></code> 相同）。</p>\n<p>这些 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionadded</span></code> 和 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionchanged</span></code> 块应该是 &quot;自包含的&quot;。换句话说，由于我们只保留这些注释两个发布版，最好能够删除注释及其内容，而不必重新排列、重新缩进或编辑周围的文本。例如，不要将新功能或更改功能的整个描述放在一个块中，而是像这样做：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">class</span><span class=\"p\">::</span> Author(first_name, last_name, middle_name=None)\n\n    A person who writes books.\n\n    <span class=\"s\">``first_name``</span> is ...\n\n<span class=\"c\">    ...</span>\n\n<span class=\"c\">    ``middle_name`` is ...</span>\n\n<span class=\"c\">    .. versionchanged:: A.B</span>\n\n<span class=\"c\">        The ``middle_name`` argument was added.</span>\n</code></pre></div>\n<p>把修改后的注解说明放在一个章节的底部，而不是顶部。</p>\n<p>另外，避免在 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionadded</span></code> 或 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionchanged</span></code> 块之外提及 Django 的特定版本。即使在代码块中，这样做也是多余的，因为这些注解分别呈现为 &quot;New in Django A.B:&quot; 和 &quot;Changed in Django A.B&quot;。</p>\n<p>如果添加了一个函数、属性等，也可以像这样使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">versionadded</span></code> 注释：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">attribute</span><span class=\"p\">::</span> Author.middle_name\n\n<span class=\"p\">    ..</span> <span class=\"ow\">versionadded</span><span class=\"p\">::</span> A.B\n\n    An author&#39;s middle name.\n</code></pre></div>\n<p>我们可以删除 <code class=\"docutils literal notranslate\"><span class=\"pre\">..</span> <span class=\"pre\">versionadded::</span> <span class=\"pre\">A.B</span></code> 注解，而不需要在时间上做任何缩进的改变。</p>\n</section>\n<section id=\"minimizing-images\">\n<h2>最小化图像<a class=\"heading-anchor\" href=\"#minimizing-images\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>尽可能地优化图像压缩。对于 PNG 文件，使用 OptiPNG 和 AdvanceCOMP 的 <code class=\"docutils literal notranslate\"><span class=\"pre\">advpng</span></code>：</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-6-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span><span class=\"nb\">cd</span><span class=\"w\"> </span>docs\n<span class=\"gp\">$ </span>optipng<span class=\"w\"> </span>-o7<span class=\"w\"> </span>-zm1-9<span class=\"w\"> </span>-i0<span class=\"w\"> </span>-strip<span class=\"w\"> </span>all<span class=\"w\"> </span><span class=\"sb\">`</span>find<span class=\"w\"> </span>.<span class=\"w\"> </span>-type<span class=\"w\"> </span>f<span class=\"w\"> </span>-not<span class=\"w\"> </span>-path<span class=\"w\"> </span><span class=\"s2\">&quot;./_build/*&quot;</span><span class=\"w\"> </span>-name<span class=\"w\"> </span><span class=\"s2\">&quot;*.png&quot;</span><span class=\"sb\">`</span>\n<span class=\"gp\">$ </span>advpng<span class=\"w\"> </span>-z4<span class=\"w\"> </span><span class=\"sb\">`</span>find<span class=\"w\"> </span>.<span class=\"w\"> </span>-type<span class=\"w\"> </span>f<span class=\"w\"> </span>-not<span class=\"w\"> </span>-path<span class=\"w\"> </span><span class=\"s2\">&quot;./_build/*&quot;</span><span class=\"w\"> </span>-name<span class=\"w\"> </span><span class=\"s2\">&quot;*.png&quot;</span><span class=\"sb\">`</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-6-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> <span class=\"k\">cd</span> docs\n<span class=\"gp\">...\\&gt;</span> optipng -o7 -zm1-9 -i0 -strip all `find . -type f -not -path <span class=\"s2\">&quot;.\\_build\\*&quot;</span> -name <span class=\"s2\">&quot;*.png&quot;</span>`\n<span class=\"gp\">...\\&gt;</span> advpng -z4 `find . -type f -not -path <span class=\"s2\">&quot;.\\_build\\*&quot;</span> -name <span class=\"s2\">&quot;*.png&quot;</span>`\n</code></pre></div></div></div>\n<p>这是基于 OptiPNG 版本 0.7.5。旧版本可能会对 <code class=\"docutils literal notranslate\"><span class=\"pre\">-strip</span> <span class=\"pre\">all</span></code> 选项进行丢失投诉。</p>\n</section>\n<section id=\"an-example\">\n<h2>一个例子<a class=\"heading-anchor\" href=\"#an-example\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>有关如何将它们组合在一起的快速示例，请考虑以下假设示例：</p>\n<ul>\n<li><p>首先， <code class=\"docutils literal notranslate\"><span class=\"pre\">ref/settings.txt</span></code> 配置文件可能具有如下总体布局：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"gh\">========</span>\n<span class=\"gh\">Settings</span>\n<span class=\"gh\">========</span>\n\n<span class=\"c\">...</span>\n\n<span class=\"p\">..</span> <span class=\"nt\">_available-settings:</span>\n\n<span class=\"gh\">Available settings</span>\n<span class=\"gh\">==================</span>\n\n<span class=\"c\">...</span>\n\n<span class=\"p\">..</span> <span class=\"nt\">_deprecated-settings:</span>\n\n<span class=\"gh\">Deprecated settings</span>\n<span class=\"gh\">===================</span>\n\n<span class=\"c\">...</span>\n</code></pre></div>\n</li>\n<li><p>接下来， <code class=\"docutils literal notranslate\"><span class=\"pre\">topics/settings.txt</span></code> 配置文档可能包含以下内容：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code>You can access a :ref:`listing of all available settings\n<span class=\"nt\">&lt;available-settings&gt;</span>`. For a list of deprecated settings see\n<span class=\"na\">:ref:</span><span class=\"nv\">`deprecated-settings`</span>.\n\nYou can find both in the :doc:`settings reference document\n<span class=\"nt\">&lt;/ref/settings&gt;</span>`.\n</code></pre></div>\n<p>当我们想要链接到另一个文档的整体时，我们使用 Sphinx 的 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/referencing.html#role-doc\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">doc</span></code></a> 交叉引用元素，而当我们想要链接到文档中的任意位置时，我们使用 <a class=\"reference external\" href=\"https://www.sphinx-doc.org/en/master/usage/referencing.html#role-ref\" title=\"(in Sphinx v9.1.1)\"><code class=\"xref rst rst-role docutils literal notranslate\"><span class=\"pre\">ref</span></code></a> 元素。</p>\n</li>\n<li><p>接下来，请注意配置的注解方式：</p>\n<div class=\"code-block\" data-language=\"rst\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Rst</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Rst code\"><code><span class=\"p\">..</span> <span class=\"ow\">setting</span><span class=\"p\">::</span> ADMINS\n\n<span class=\"gh\">ADMINS</span>\n<span class=\"gh\">======</span>\n\nDefault: <span class=\"s\">``[]``</span> (Empty list)\n\nA list of all the people who get code error notifications. When\n<span class=\"s\">``DEBUG=False``</span> and a view raises an exception, Django will email these people\nwith the full exception information. Each member of the list should be a tuple\nof (Full name, email address). Example<span class=\"se\">::</span>\n\n<span class=\"s\">    [(&quot;John&quot;, &quot;john@example.com&quot;), (&quot;Mary&quot;, &quot;mary@example.com&quot;)]</span>\n\nNote that Django will email <span class=\"ge\">*all*</span> of these people whenever an error happens.\nSee <span class=\"na\">:doc:</span><span class=\"nv\">`/howto/error-reporting`</span> for more information.\n</code></pre></div>\n<p>这标志着下面的标题是配置 <code class=\"docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code> 的 “标准” 目标。这意味着当我谈到 <code class=\"docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code> 时，我可以用 <code class=\"docutils literal notranslate\"><span class=\"pre\">:setting:`ADMINS`</span></code> 来引用它。</p>\n</li>\n</ul>\n<p>基本上，这就是所有东西融合在一起的方式。</p>\n</section>\n<section id=\"translating-documentation\">\n<h2>翻译文档<a class=\"heading-anchor\" href=\"#translating-documentation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>查看 <a class=\"reference internal\" href=\"/zh-hans/5.2/internals/contributing/localizing/#translating-documentation\"><span class=\"std std-ref\">本地化 Django 文档</span></a>，如果你想帮助我们将文档翻译成其它语言。</p>\n</section>\n<section id=\"django-admin-man-page\">\n<span id=\"django-admin-manpage\"></span><h2><code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> 手册页面<a class=\"heading-anchor\" href=\"#django-admin-man-page\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Sphinx 可以为 <a class=\"reference internal\" href=\"/zh-hans/5.2/ref/django-admin/\"><span class=\"doc\">django-admin</span></a> 命令生成一个手册页。这是在 <code class=\"docutils literal notranslate\"><span class=\"pre\">docs/conf.py</span></code> 中配置的。与其他文档输出不同，这个手册页应该包含在 Django 仓库和版本中，作为 <code class=\"docutils literal notranslate\"><span class=\"pre\">docs/man/django-admin.1</span></code>。在更新文档时不需要更新这个文件，因为它作为发行过程的一部分被更新一次。</p>\n<p>To generate an updated version of the man page, in the <code class=\"docutils literal notranslate\"><span class=\"pre\">docs</span></code> directory, run:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-7-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>make<span class=\"w\"> </span>man\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-7-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> make.bat man\n</code></pre></div></div></div>\n<p>The new man page will be written in <code class=\"docutils literal notranslate\"><span class=\"pre\">docs/_build/man/django-admin.1</span></code>.</p>\n</section>","rootId":"writing-documentation","toc":[{"title":"Django 文档编写流程","anchor":"the-django-documentation-process","children":[]},{"title":"文档是如何组成","anchor":"how-the-documentation-is-organized","children":[]},{"title":"如何开始贡献文档","anchor":"how-to-start-contributing-documentation","children":[{"title":"克隆 Django 存储库到您的本地计算机","anchor":"clone-the-django-repository-to-your-local-machine","children":[]},{"title":"建立一个虚拟环境并安装依赖项","anchor":"set-up-a-virtual-environment-and-install-dependencies","children":[]},{"title":"在本地构建文档","anchor":"build-the-documentation-locally","children":[]},{"title":"对文档进行编辑","anchor":"making-edits-to-the-documentation","children":[]},{"title":"Documentation quality checks","anchor":"documentation-quality-checks","children":[{"title":"拼写检查","anchor":"spelling-check","children":[]},{"title":"Code block format check","anchor":"code-block-format-check","children":[]}]},{"title":"链接检查","anchor":"link-check","children":[]}]},{"title":"书写格式","anchor":"writing-style","children":[]},{"title":"常用术语","anchor":"commonly-used-terms","children":[]},{"title":"Django 专用术语","anchor":"django-specific-terminology","children":[]},{"title":"reStructuredText 文件语法指南","anchor":"guidelines-for-restructuredtext-files","children":[]},{"title":"Django 特有的标记","anchor":"django-specific-markup","children":[]},{"title":"记录新功能","anchor":"documenting-new-features","children":[]},{"title":"最小化图像","anchor":"minimizing-images","children":[]},{"title":"一个例子","anchor":"an-example","children":[]},{"title":"翻译文档","anchor":"translating-documentation","children":[]},{"title":"django-admin 手册页面","anchor":"django-admin-man-page","children":[]}],"breadcrumbs":[{"docname":"internals/index","title":"Django内部","url":"/zh-hans/5.2/internals/"},{"docname":"internals/contributing/index","title":"为 Django 做贡献","url":"/zh-hans/5.2/internals/contributing/"}],"prev":{"docname":"internals/contributing/committing-code","title":"提交代码","url":"/zh-hans/5.2/internals/contributing/committing-code/"},"next":{"docname":"internals/contributing/localizing","title":"使 Django 本地化","url":"/zh-hans/5.2/internals/contributing/localizing/"},"formats":{"html":"/zh-hans/5.2/internals/contributing/writing-documentation/","markdown":"/zh-hans/5.2/internals/contributing/writing-documentation.md","json":"/zh-hans/5.2/internals/contributing/writing-documentation.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/internals/contributing/writing-documentation.txt","official":"https://docs.djangoproject.com/zh-hans/5.2/internals/contributing/writing-documentation/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}