문서 작성하기¶
We place high importance on the consistency and readability of documentation. After all, Django was created in a journalism environment! So we treat our documentation like we treat our code: we aim to improve it as often as possible.
문서 변경은 다음 두 가지 형태로 이뤄집니다.
일반적인 개선: 오탈자 수정, 명료한 문장과 더 많은 예제를 통한 오류 수정 및 예제 개선.
새로운 기능: 최종 릴리스 이후에 프레임워크에 추가된 기능에 대한 문서화.
이 절에서는 저자들이 어떻게 유용하고도 오류를 적게 일으키는 방식으로 문서 변경을 다루는지 설명합니다.
The Django documentation process¶
Though Django’s documentation is intended to be read as HTML at https://docs.djangoproject.com/, we edit it as a collection of plain text files written in the reStructuredText markup language for maximum flexibility.
We work from the development version of the repository because it has the latest-and-greatest documentation, just as it has the latest-and-greatest code.
We also backport documentation fixes and improvements, at the discretion of the merger, to the last release branch. This is because it’s advantageous to have the docs for the last release be up-to-date and correct (see 버전 간 차이점).
Django 문서는 docutils를 기반으로 하는 Sphinx 문서화 시스템을 사용합니다. Sphinx는 가벼운 형식의 일반 텍스트 문서를 HTML, PDF, 기타 여러 형식으로 변환해줍니다.
Sphinx includes a sphinx-build
command for turning reStructuredText into
other formats, e.g., HTML and PDF. This command is configurable, but the Django
documentation includes a Makefile
that provides a shorter make html
command.
이 문서의 구조¶
문서는 여러 범주로 나뉩니다.
튜토리얼은 독자로 하여금 차근차근 따라 하면서 뭔가 만들어 볼 수 있도록 해줍니다.
튜토리얼에서 가장 중요한 것은 독자가 최대한 빠르게 유용한 것을 만들어 봄으로써 자신감을 갖도록 하는 것입니다.
Explain the nature of the problem we’re solving, so that the reader understands what we’re trying to achieve. Don’t feel that you need to begin with explanations of how things work - what matters is what the reader does, not what you explain. It can be helpful to refer back to what you’ve done and explain afterward.
주제 가이드는 개념 또는 주제를 고수준에서 설명하는 것을 목적으로 합니다.
참고 자료에 있는 내용을 반복하지 말고 링크를 거세요. 예제를 사용하고, 매우 기초적인 내용에 대한 설명을 아끼지 마세요. 그런 설명을 필요로 하는 사람이 있을 지 모릅니다.
해당 주제를 처음 접하는 사람들을 위해 배경 지식을 설명하는 것은 그들이 이미 알고 있는 것과 연결하는 데 도움이 됩니다.
Reference guides contain technical references for APIs. They describe the functioning of Django’s internal machinery and instruct in its use.
참고 자료는 주제에 집중해야 합니다. 독자가 이미 기본 개념을 알고 있되 Django에서 그것을 어떻게 다루는지에 대한 설명이 필요할 것으로 가정하세요.
참조 가이드는 일반적인 설명을 위한 것이 아닙니다. 기본 개념에 대해 설명하고 있다고 느껴지면, 그것을 주제 가이드로 옮기기 바랍니다.
How-to 가이드는 주요한 주제에 있어서 독자가 따라할 수 있는 레시피입니다.
how-to 가이드에서는 사용자가 달성하고자 하는 것이 중요합니다. how-to에서는 Django의 내부 구현에 대한 세부 사항보다는 결과물을 도출하는 데 집중해야 합니다.
how-to 가이드는 튜토리얼보다 수준이 높으며, 독자가 Django의 동작 원리에 대한 지식이 있을 것으로 간주합니다. 독자가 이미 튜토리얼을 읽은 것으로 간주하고, 같은 내용을 반복하지 말고 관련 튜토리얼에 대한 참조를 제공하세요.
How to start contributing documentation¶
Clone the Django repository to your local machine¶
If you’d like to start contributing to our docs, get the development version of Django from the source code repository (see Installing the development version):
$ git clone https://github.com/django/django.git
...\> git clone https://github.com/django/django.git
If you’re planning to submit these changes, you might find it useful to make a fork of the Django repository and clone this fork instead.
Set up a virtual environment and install dependencies¶
Create and activate a virtual environment, then install the dependencies:
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install -r docs/requirements.txt
Build the documentation locally¶
We can build HTML output from the docs
directory:
$ cd docs
$ make html
...\> cd docs
...\> make.bat html
Your locally-built documentation will be accessible at
_build/html/index.html
and it can be viewed in any web browser, though it
will be themed differently than the documentation at
docs.djangoproject.com. This is OK! If
your changes look good on your local machine, they’ll look good on the website.
Making edits to the documentation¶
The source files are .txt
files located in the docs/
directory.
These files are written in the reStructuredText markup language. To learn the markup, see the reStructuredText reference.
To edit this page, for example, we would edit the file
docs/internals/contributing/writing-documentation.txt and rebuild the
HTML with make html
.
철자 확인¶
Before you commit your docs, it’s a good idea to run the spelling checker.
You’ll need to install sphinxcontrib-spelling first. Then from the
docs
directory, run:
$ make spelling
...\> make.bat spelling
Wrong words (if any) along with the file and line number where they occur will
be saved to _build/spelling/output.txt
.
False Positive(실제로 정확한 오류 출력)가 발생하는 경우 다음 중 하나를 수행합니다.
Surround inline code or brand/technology names with double grave accents (``).
철자 검사기가 인식하는 동의어를 찾습니다.
사용 중인 단어가 정확하다고 확신하는 경우에만 “docs/spelling_wordlist”에 추가합니다(목록은 알파벳 순으로 유지).
링크체크¶
Links in documentation can become broken or changed such that they are no
longer the canonical link. Sphinx provides a builder that can check whether the
links in the documentation are working. From the docs
directory, run:
$ make linkcheck
...\> make.bat linkcheck
Output is printed to the terminal, but can also be found in
_build/linkcheck/output.txt
and _build/linkcheck/output.json
.
경고
The execution of the command requires an internet connection and takes several minutes to complete, because the command tests all the links that are found in the documentation.
상태가 “작동 중”인 항목은 정상이며, “선택 취소됨” 또는 “무시됨” 항목은 확인할 수 없거나 구성의 무시 규칙과 일치하기 때문에 건너뜁니다.
Entries that have a status of “broken” need to be fixed. Those that have a
status of “redirected” may need to be updated to point to the canonical
location, e.g. the scheme has changed http://
→ https://
. In certain
cases, we do not want to update a “redirected” link, e.g. a rewrite to always
point to the latest or stable version of the documentation, e.g. /en/stable/
→
/en/3.2/
.
문체¶
When using pronouns in reference to a hypothetical person, such as “a user with a session cookie”, gender-neutral pronouns (they/their/them) should be used. Instead of:
he 또는 she 대신 they를 사용합니다.
him 또는 her 대신 them을 사용합니다.
his 또는 her 대신 their를 사용합니다.
his 또는 hers 대신 theirs를 사용합니다.
himself 또는 herself 대신 themselves를 사용합니다.
Try to avoid using words that minimize the difficulty involved in a task or operation, such as “easily”, “simply”, “just”, “merely”, “straightforward”, and so on. People’s experience may not match your expectations, and they may become frustrated when they do not find a step as “straightforward” or “simple” as it is implied to be.
공통적인 용어¶
다음은 문서에서 공통적으로 사용되는 용어에 대한 지침입니다.
Django – 프레임워크를 지칭할 때에는 첫 글자를 대문자로 하여 Django로 표기합니다. Python 코드와 djangoproject.com 로고에서만 소문자를 사용합니다.
email – 하이픈을 넣지 않습니다.
HTTP – the expected pronunciation is “Aitch Tee Tee Pee” and therefore should be preceded by “an” and not “a”.
MySQL, PostgreSQL, SQLite
SQL – SQL을 가리킬 때, 그 발음은 “시퀄”이 아니라 “에스큐엘”로 합니다. 따라서 “Returns an SQL expression”과 같은 표현에서 “SQL” 앞에는 “a”가 아닌 “an”이 옵니다.
Python – 언어를 가리킬 때에는 첫 글자를 대문자로 하여 Python으로 표기합니다.
realize, customize, initialize 등. – 미국식으로 “ize”를 붙이며, “ise”는 붙이지 않습니다.
subclass – 하이픈이 없는 하나의 단어로, 동사(“subclass that model”) 또는 명사(“create a subclass”)입니다.
the web, web framework – it’s not capitalized.
website – 대문자 없이 한 단어로 씁니다.
Django 관련 용어¶
model – 대문자가 아닙니다.
template – 대문자가 아닙니다.
URLconf – 처음 세 글자를 대문자로 하며, “conf”와의 사이에 공백을 두지 않습니다.
view – 대문자가 아닙니다.
reStructuredText 파일 안내¶
These guidelines regulate the format of our reST (reStructuredText) documentation:
In section titles, capitalize only initial words and proper nouns.
Wrap the documentation at 80 characters wide, unless a code example is significantly less readable when split over two lines, or for another good reason.
The main thing to keep in mind as you write and edit docs is that the more semantic markup you can add the better. So:
Add ``django.contrib.auth`` to your ``INSTALLED_APPS``...
Isn’t nearly as helpful as:
Add :mod:`django.contrib.auth` to your :setting:`INSTALLED_APPS`...
This is because Sphinx will generate proper links for the latter, which greatly helps readers.
You can prefix the target with a
~
(that’s a tilde) to get only the “last bit” of that path. So:mod:`~django.contrib.auth`
will display a link with the title “auth”.All Python code blocks should be formatted using the blacken-docs auto-formatter. This will be run by pre-commit if that is configured.
Use
intersphinx
to reference Python’s and Sphinx’ documentation.Add
.. code-block:: <lang>
to literal blocks so that they get highlighted. Prefer relying on automatic highlighting using::
(two colons). This has the benefit that if the code contains some invalid syntax, it won’t be highlighted. Adding.. code-block:: python
, for example, will force highlighting despite invalid syntax.To improve readability, use
.. admonition:: Descriptive title
rather than.. note::
. Use these boxes sparingly.Use these heading styles:
=== One === Two === Three ----- Four ~~~~ Five ^^^^
Use
:rfc:
to reference a Request for Comments (RFC) and try to link to the relevant section if possible. For example, use:rfc:`2324#section-2.3.2`
or:rfc:`Custom link text <2324#section-2.3.2>`
.Use
:pep:
to reference a Python Enhancement Proposal (PEP) and try to link to the relevant section if possible. For example, use:pep:`20#easter-egg`
or:pep:`Easter Egg <20#easter-egg>`
.Use
:mimetype:
to refer to a MIME Type unless the value is quoted for a code example.Use
:envvar:
to refer to an environment variable. You may also need to define a reference to the documentation for that environment variable using.. envvar::
.Use
:cve:
to reference a Common Vulnerabilities and Exposures (CVE) identifier. For example, use:cve:`2019-14232`
.
Django-specific markup¶
Besides Sphinx’s built-in markup, Django’s docs define some extra description units:
Settings:
.. setting:: INSTALLED_APPS
설정에 연결하려면
:setting:`INSTALLED_APPS`
을 사용하십시오.Template tags:
.. templatetag:: regroup
Template filters:
.. templatefilter:: linebreaksbr
연결하려면``:tfilter:`linebreaksbr```를 이용하십시오.
Field lookups (i.e.
Foo.objects.filter(bar__exact=whatever)
):.. fieldlookup:: exact
연결하려면````:lookup:`exact``````를 이용하십시오.
django-admin
commands:.. django-admin:: migrate
연결하려면``:djadmin:`migrate```를 이용하십시오.
django-admin
command-line options:.. django-admin-option:: --traceback
To link, use
:option:`command_name --traceback`
(or omitcommand_name
for the options shared by all commands like--verbosity
).Links to Trac tickets (typically reserved for patch release notes):
:ticket:`12345`
장고의 문서에는 “장고-admin”, “관리”와 관련된 명령줄 예를 문서화하기 위해 사용자 정의 “콘솔” 지시문이 사용된다.py``, python
, etc.). HTML 문서에서는 두 탭 UI를 렌더링하며, 한 탭은 유닉스 스타일의 명령 프롬프트를, 두 번째 탭은 윈도우 프롬프트를 보여준다.
For example, you can replace this fragment:
use this command:
.. code-block:: console
$ python manage.py shell
with this one:
use this command:
.. console::
$ python manage.py shell
다음 두 가지를 주목하십시오.
일반적으로
.. code-block:: console
지시문의 항목을 대체합니다.You don’t need to change the actual content of the code example. You still write it assuming a Unix-y environment (i.e. a
'$'
prompt symbol,'/'
as filesystem path components separator, etc.)
위의 예제에서는 두 개의 탭이 있는 코드 예제 블록을 렌더링합니다. 첫 번째 항목은 다음과 같습니다.
$ python manage.py shell
(``.. code-block:: console``에서 렌더링한 변경 사항은 없습니다.)
두 번째 항목은 다음과 같습니다.
...\> py manage.py shell
새로운 기능을 문서화합니다.¶
새로운 기능에 대한 당사의 정책은 다음과 같습니다.
All documentation of new features should be written in a way that clearly designates the features that are only available in the Django development version. Assume documentation readers are using the latest release, not the development version.
Our preferred way for marking new features is by prefacing the features’
documentation with: “.. versionadded:: X.Y
”, followed by a mandatory
blank line and an optional description (indented).
General improvements or other changes to the APIs that should be emphasized
should use the “.. versionchanged:: X.Y
” directive (with the same format
as the versionadded
mentioned above.
These versionadded
and versionchanged
blocks should be “self-contained.”
In other words, since we only keep these annotations around for two releases,
it’s nice to be able to remove the annotation and its contents without having
to reflow, reindent, or edit the surrounding text. For example, instead of
putting the entire description of a new or changed feature in a block, do
something like this:
.. class:: Author(first_name, last_name, middle_name=None)
A person who writes books.
``first_name`` is ...
...
``middle_name`` is ...
.. versionchanged:: A.B
The ``middle_name`` argument was added.
변경된 주석 노트를 맨 위가 아닌 섹션 맨 아래에 배치합니다.
Also, avoid referring to a specific version of Django outside a
versionadded
or versionchanged
block. Even inside a block, it’s often
redundant to do so as these annotations render as “New in Django A.B:” and
“Changed in Django A.B”, respectively.
If a function, attribute, etc. is added, it’s also okay to use a
versionadded
annotation like this:
.. attribute:: Author.middle_name
.. versionadded:: A.B
An author's middle name.
We can remove the .. versionadded:: A.B
annotation without any indentation
changes when the time comes.
이미지 최소화¶
가능한 경우 이미지 압축을 최적화합니다. PNG 파일의 경우 OptiPNG 및 Advanced를 사용합니다.COMP의 ‘’advpng’’:
$ cd docs
$ optipng -o7 -zm1-9 -i0 -strip all `find . -type f -not -path "./_build/*" -name "*.png"`
$ advpng -z4 `find . -type f -not -path "./_build/*" -name "*.png"`
...\> cd docs
...\> optipng -o7 -zm1-9 -i0 -strip all `find . -type f -not -path ".\_build\*" -name "*.png"`
...\> advpng -z4 `find . -type f -not -path ".\_build\*" -name "*.png"`
이 버전은 OptiPNG 버전 0.7.5를 기반으로 합니다. 구 버전에서는 “-스트라이프 올” 옵션이 상실되는 것에 대해 불평할 수도 있습니다.
예제:¶
이 모든 것이 어떻게 서로 들어맞는지에 대한 간단한 예제를 보려면 다음 가상 예를 고려해 보십시오.
먼저 ‘’참조/설정’’입니다.txt document 문서의 전체 레이아웃은 다음과 같습니다.
======== Settings ======== ... .. _available-settings: Available settings ================== ... .. _deprecated-settings: Deprecated settings =================== ...
다음은 ‘’주제/설정’’입니다.txt 문서에는 다음과 같은 내용이 포함될 수 있습니다.
You can access a :ref:`listing of all available settings <available-settings>`. For a list of deprecated settings see :ref:`deprecated-settings`. You can find both in the :doc:`settings reference document </ref/settings>`.
We use the Sphinx
doc
cross-reference element when we want to link to another document as a whole and theref
element when we want to link to an arbitrary location in a document.그런 다음 설정에 주석을 달 수 있습니다.
.. setting:: ADMINS ADMINS ====== Default: ``[]`` (Empty list) A list of all the people who get code error notifications. When ``DEBUG=False`` and a view raises an exception, Django will email these people with the full exception information. Each member of the list should be a tuple of (Full name, email address). Example:: [("John", "[email protected]"), ("Mary", "[email protected]")] Note that Django will email *all* of these people whenever an error happens. See :doc:`/howto/error-reporting` for more information.
This marks up the following header as the “canonical” target for the setting
ADMINS
. This means any time I talk aboutADMINS
, I can reference it using:setting:`ADMINS`
.
기본적으로 모든 것이 서로 맞아떨어집니다.
번역 문서¶
참조:ref:문서를 다른 언어로 번역하려면 “장고 문서 현지화”를 참조하십시오.
‘’dango-admin’ man 페이지¶
Sphinx can generate a manual page for the
django-admin command. This is configured in
docs/conf.py
. Unlike other documentation output, this man page should be
included in the Django repository and the releases as
docs/man/django-admin.1
. There isn’t a need to update this file when
updating the documentation, as it’s updated once as part of the release process.
To generate an updated version of the man page, in the docs
directory, run:
$ make man
...\> make.bat man
The new man page will be written in docs/_build/man/django-admin.1
.