Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | .. highlightlang:: rest |
| 2 | |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 3 | Style guide |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 4 | =========== |
| 5 | |
| 6 | The Python documentation should follow the `Apple Publications Style Guide`_ |
| 7 | wherever possible. This particular style guide was selected mostly because it |
| 8 | seems reasonable and is easy to get online. |
| 9 | |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 10 | Topics which are either not covered in Apple's style guide or treated |
| 11 | differently in Python documentation will be discussed in this |
| 12 | document. |
| 13 | |
| 14 | Use of whitespace |
| 15 | ----------------- |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 16 | |
Georg Brandl | 2592f62 | 2011-03-20 18:14:07 +0000 | [diff] [blame^] | 17 | All reST files use an indentation of 3 spaces; no tabs are allowed. The |
| 18 | maximum line length is 80 characters for normal text, but tables, deeply |
| 19 | indented code samples and long links may extend beyond that. Code example |
| 20 | bodies should use normal Python 4-space indentation. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 21 | |
| 22 | Make generous use of blank lines where applicable; they help grouping things |
| 23 | together. |
| 24 | |
| 25 | A sentence-ending period may be followed by one or two spaces; while reST |
| 26 | ignores the second space, it is customarily put in by some users, for example |
| 27 | to aid Emacs' auto-fill mode. |
| 28 | |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 29 | Footnotes |
| 30 | --------- |
| 31 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 32 | Footnotes are generally discouraged, though they may be used when they are the |
| 33 | best way to present specific information. When a footnote reference is added at |
| 34 | the end of the sentence, it should follow the sentence-ending punctuation. The |
| 35 | reST markup should appear something like this:: |
| 36 | |
| 37 | This sentence has a footnote reference. [#]_ This is the next sentence. |
| 38 | |
| 39 | Footnotes should be gathered at the end of a file, or if the file is very long, |
| 40 | at the end of a section. The docutils will automatically create backlinks to |
| 41 | the footnote reference. |
| 42 | |
| 43 | Footnotes may appear in the middle of sentences where appropriate. |
| 44 | |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 45 | Capitalization |
| 46 | -------------- |
| 47 | |
| 48 | .. sidebar:: Sentence case |
| 49 | |
| 50 | Sentence case is a set of capitalization rules used in English |
| 51 | sentences: the first word is always capitalized and other words are |
| 52 | only capitalized if there is a specific rule requiring it. |
| 53 | |
| 54 | Apple style guide recommends the use of title case in section titles. |
| 55 | However, rules for which words should be capitalized in title case |
| 56 | vary greaty between publications. |
| 57 | |
| 58 | In Python documentation, use of sentence case in section titles is |
| 59 | preferable, but consistency within a unit is more important than |
| 60 | following this rule. If you add a section to the chapter where most |
| 61 | sections are in title case you can either convert all titles to |
| 62 | sentence case or use the dominant style in the new section title. |
| 63 | |
| 64 | Sentences that start with a word for which specific rules require |
| 65 | starting it with a lower case letter should be avoided in titles and |
| 66 | elsewhere. |
| 67 | |
| 68 | .. note:: |
| 69 | |
| 70 | Sections that describe a library module often have titles in the |
| 71 | form of "modulename --- Short description of the module." In this |
| 72 | case, the description should be capitalized as a stand-alone |
| 73 | sentence. |
| 74 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 75 | Many special names are used in the Python documentation, including the names of |
| 76 | operating systems, programming languages, standards bodies, and the like. Most |
| 77 | of these entities are not assigned any special markup, but the preferred |
| 78 | spellings are given here to aid authors in maintaining the consistency of |
| 79 | presentation in the Python documentation. |
| 80 | |
| 81 | Other terms and words deserve special mention as well; these conventions should |
| 82 | be used to ensure consistency throughout the documentation: |
| 83 | |
| 84 | CPU |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 85 | For "central processing unit." Many style guides say this should be |
| 86 | spelled out on the first use (and if you must use it, do so!). For |
| 87 | the Python documentation, this abbreviation should be avoided since |
| 88 | there's no reasonable way to predict which occurrence will be the |
| 89 | first seen by the reader. It is better to use the word "processor" |
| 90 | instead. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 91 | |
| 92 | POSIX |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 93 | The name assigned to a particular group of standards. This is always |
| 94 | uppercase. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 95 | |
| 96 | Python |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 97 | The name of our favorite programming language is always capitalized. |
| 98 | |
| 99 | reST |
| 100 | For "reStructuredText," an easy to read, plaintext markup syntax |
| 101 | used to produce Python documentation. When spelled out, it is |
| 102 | always one word and both forms start with a lower case 'r'. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 103 | |
| 104 | Unicode |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 105 | The name of a character coding system. This is always written |
| 106 | capitalized. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 107 | |
| 108 | Unix |
Alexander Belopolsky | ea3e91e | 2010-11-11 22:43:45 +0000 | [diff] [blame] | 109 | The name of the operating system developed at AT&T Bell Labs in the early |
| 110 | 1970s. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 111 | |
| 112 | |
Georg Brandl | 386bc6d | 2010-04-25 10:19:53 +0000 | [diff] [blame] | 113 | .. _Apple Publications Style Guide: http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/APStyleGuide/APSG_2009.pdf |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 114 | |