GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing devguide.python.org — Style guide Style guide¶This page describes the linguistic style guide for our documentation. For markup details in reST files, see reStructuredText markup. Footnotes¶Footnotes are generally discouraged, though they may be used when they are the best way to present specific information. When a footnote reference is added at the end of the sentence, it should follow the sentence-ending punctuation. The reST markup should appear something like this: This sentence has a footnote reference. [#]_ This is the next sentence.
Footnotes should be gathered at the end of a file, or if the file is very long, at the end of a section. The docutils will automatically create backlinks to the footnote reference. Footnotes may appear in the middle of sentences where appropriate. Capitalization¶In the Python documentation, the use of sentence case in section titles is preferable, but consistency within a unit is more important than following this rule. If you add a section to a chapter where most sections are in title case, you can either convert all titles to sentence case or use the dominant style in the new section title. Sentences that start with a word for which specific rules require starting it with a lowercase letter should be avoided. Note Sections that describe a library module often have titles in the form of “modulename — Short description of the module.” In this case, the description should be capitalized as a stand-alone sentence. Many special names are used in the Python documentation, including the names of operating systems, programming languages, standards bodies, and the like. Most of these entities are not assigned any special markup, but the preferred spellings are given in Specific words to aid authors in maintaining the consistency of presentation in the Python documentation. Use simple language¶Avoid esoteric phrasing where possible. Our audience is world-wide and may not be native English speakers. Don’t use Latin abbreviations like “e.g.” or “i.e.” where English words will do, such as “for example” or “that is.” In general, the first time an acronym or abbreviation is used on a page, spell it out. Prefer to write out the full term and follow it with the acronym in parentheses. For example, write “Basic Multilingual Plane (BMP)”. Commonly understood acronyms, such as “HTML” and “UTF-8”, should not be expanded. Charged terminology to avoid¶Avoid terminology that may be considered insensitive or exclusionary.
Specific words¶Some terms and words deserve special mention. These conventions should be used to ensure consistency throughout the documentation:
Type names¶When writing the names of types in prose, indicate that the name is a type by
writing the name of the type exactly as it appears in source, styled as a class
reference or an unlinked class. For example, refer to dict as Links should be used according to the guidance on links. Some type names are commonly understood ideas or nouns outside of Python.
For example, “tuples” are a general programming concept, as distinct from the
Many types have descriptive names which may or may not exactly match their type
name. For example, “context variables” describes Descriptive names should be written as common nouns, meaning they are lowercase when not at the start of a sentence or phrase. Diátaxis¶Python’s documentation strives to follow the Diátaxis framework. This means adapting the writing style according to the nature of the documentation that is being written. The framework splits documentation into four distinct types: tutorials, how-to guides, reference, and explanation.
Please consult the Diátaxis guide for more detail. Links¶Links are a powerful tool for helping people navigate documentation and find more information, but links can be over-used. Links should be used only if they help the reader. Generally, a link should be provided for the first use of a term in a unit, such as a section or paragraph. This is not a hard and fast rule. Sometimes the second mention is more appropriate for a link. Some units are long enough to have a few repeated links. Use judgement to decide when a link will help the reader. We use the linklint Sphinx extension to suppress two kinds
of excessive links: references in a section to itself and duplicate references
in a paragraph. Previously, editors had to carefully use an exclamation mark
in a Sphinx reference ( Do not use links in section headers. They distract from the title of the section. The term will be mentioned in the paragraph text and can be linked from there. Sphinx automatically adds links to references, and provides a way to
suppress the link. Using roles like Affirmative tone¶The documentation focuses on affirmatively stating what the language does and how to use it effectively. Except for certain security or segfault risks, the docs should avoid wording along the lines of “feature x is dangerous” or “experts only”. These kinds of value judgments belong in external blogs and wikis, not in the core documentation. Bad example (creating worry in the mind of a reader):
Good example (establishing confident knowledge in the effective use of the language):
Author attribution¶For new documentation, do not use a byline (naming the author of the document). Explicit attribution tends to discourage other users from updating community documentation. Existing bylines are for historical interest only. They do not imply ownership or necessary approvals, and do not prevent edits or updates by others. Pronunciation of dunder names¶“Dunder names” like Economy of expression¶More documentation is not necessarily better documentation. Err on the side of being succinct. It is an unfortunate fact that making documentation longer can be an impediment to understanding and can result in even more ways to misread or misinterpret the text. Long descriptions full of corner cases and caveats can create the impression that a function is more complex or harder to use than it actually is. Security considerations (and other concerns)¶Some modules provided with Python are inherently exposed to security issues
(for example, shell injection vulnerabilities) due to the purpose of the module
(for example, Instead, these security concerns should be gathered into a dedicated
“Security Considerations” section within the module’s documentation, and
cross-referenced from the documentation of affected interfaces with a note
similar to Similarly, if there is a common error that affects many interfaces in a module (for example, OS level pipe buffers filling up and stalling child processes), these can be documented in a “Common Errors” section and cross-referenced rather than repeated for every affected interface. Code examples¶Short code examples can be a useful adjunct to understanding. Readers can often grasp a simple example more quickly than they can digest a formal description in prose. People learn faster with concrete, motivating examples that match the context of
a typical use case. For instance, the When writing interactive examples, keep prompt style consistent and copy-friendly:
For the reST markup used to present interactive sessions, see Showing code examples. Code equivalents¶Giving pure Python code equivalents (or approximate equivalents) can be a useful adjunct to a prose description. A documenter should carefully weigh whether the code equivalent adds value. A good example is the code equivalent for A more questionable example is the code for An example of when not to use a code equivalent is for the Audience¶The tone of the tutorial (and all the docs) needs to be respectful of the reader’s intelligence. Don’t presume that the readers are stupid. Lay out the relevant information, show motivating use cases, provide glossary links, and do your best to connect-the-dots, but don’t talk down to them or waste their time. The tutorial is meant for newcomers, many of whom will be using the tutorial to evaluate the language as a whole. The experience needs to be positive and not leave the reader with worries that something bad will happen if they make a misstep. The tutorial serves as a guide for intelligent and curious readers, saving details for the how-to guides and other sources. Be careful accepting requests for documentation changes from the rare but vocal category of reader who is looking for vindication for one of their programming errors (“I made a mistake, therefore the docs must be wrong …”). Typically, the documentation wasn’t consulted until after the error was made. It is unfortunate, but typically no documentation edit would have saved the user from making false assumptions about the language (“I was surprised by …”). Function signatures¶These are the evolving guidelines for how to include function signatures in the reference guide. As outlined in Diátaxis, reference material should prioritize precision and completeness.
| ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |