File: style-guide.rst

package info (click to toggle)
astropy 7.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 35,328 kB
  • sloc: python: 233,437; ansic: 55,264; javascript: 17,680; lex: 8,621; sh: 3,317; xml: 2,287; makefile: 191
file content (355 lines) | stat: -rw-r--r-- 12,052 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
.. _astropy-style-guide:

*****************************
Astropy Narrative Style Guide
*****************************

The purpose of this style guide is to provide the Astropy community with a set
of style and formatting guidelines that can be referenced when writing Astropy
documentation. Following the guidelines offered in this style guide will bring
greater consistency and clarity to Astropy's documentation, supporting its
mission to develop a common core package for Astronomy in Python and foster an
ecosystem of interoperable astronomy packages.

This style guide is organized alphabetically by writing topic, with usage
examples in each section, and tone and formatting guidelines at the end.

Abbreviations
=============

Place abbreviations such as i.e. and e.g. within parentheses, where they are
followed by a comma. Alternatively, consider using "that is" and “for example”
instead, preceded by an em dash or semicolon and followed by a comma, or
contained within em dashes.

Examples
--------
* The only way to modify the data in a frame is by using the ``data`` attribute
  directly and not the aliases for components on the frame (i.e., the following
  will not work).
* There are no plans to support more complex evolution (e.g., non-inertial
  frames or more complex evolution), as that is out of scope for the ``astropy``
  core.
* Once you have a coordinate object you can access the components of that
  coordinate — for example, RA or Dec — to get string representations of the
  full coordinate.

For general use and scientific terms, use abbreviations only when the
abbreviated term is well-known and widely used within the astronomy community.
For less common scientific terms, or terms specific to a given field, write out
the term or link to a resource of explanation. A good rule of thumb to follow
when deciding whether or not something should be abbreviated is: when in doubt,
write it out.

Examples
--------
* 1D, 2D, etc. is preferred over one-dimensional, two-dimensional, etc.
* Units such as SI and CGS can be abbreviated as is more commonly seen in the
  scientific community.
* White dwarf should be written out fully instead of abbreviated as WD.
* Names of organizations or other proper nouns that employ acronyms should be
  written as their known acronym, but with a hyperlink to a website or resource
  for reference, for instance, `CODATA <https://codata.org/>`_.

Capitalization
==============

Capitalize all proper nouns (names) in plain text, except when referring to
package/code names, in which case use lowercase and double backticks. Astropy
capitalized refers to The Astropy Project, while ``astropy`` lowercase and in
backticks refers to the core package.

Examples
--------
* Follow Astropy guidelines for contributing code.
* Affiliated packages are astronomy-related software packages that are not part
  of the ``astropy`` core package.
* Provide a code example along with details of the operating system and the
  Python, ``numpy``, and ``astropy`` versions you are using.

In Documentation materials, title case capitalization is preferred in headings,
meaning capitalize first, last, and all major words in the heading, but
lowercase articles (the, a, an), prepositions (at, to, up, down, with, in,
etc.), and common coordinating conjunctions (and, but, for, or). Sentence case
capitalization is acceptable for longer example headings.

Examples
--------
* Building and Installing
* Frames without Data
* Checklist for Contributing Code
* Astropy Guidelines
* Importing ``astropy`` and Subpackages
* Example: Use velocity to compute sky position at different epochs

In Tutorials and other learning materials, title case capitalization is
preferred in headings of structured introductory/template sections, but within
the tutorial, sentence case (i.e., capitalize first word and proper nouns only)
is acceptable for longer headings designating different learning/code sections.

Contractions
============

Do not use contractions in formal documentation material.

Examples
--------
* If you are making changes that impact ``astropy`` performance, consider adding
  a performance benchmark.
* You do not need to include a changelog entry.

In all other materials, avoid use of contractions only when the tense can be
confused, such as in the case of “she is gone” versus “she has gone,” etc.

.. _Hyphenation:

Hyphenation
===========

Phrasal adjectives/compound modifiers placed before a noun should be hyphenated
to avoid confusion.

Examples
--------
* Astronomy-related software packages.
* Astropy provides sustainable, high-level education to the astronomy community.

Hyphenated compound words should contain hyphens in plain text, but no hyphens
in code.

Example
-------
* Do not forget to double-check your formatting.

Numbers
=======

For numbers followed by a unit or as part of a name, use the numeral.

Examples
--------
* 1 arcminute
* 32 degrees
* Gaia data release 2 catalog
* 1D, 2D, etc. is preferred over one-dimensional, two-dimensional, etc.

For all other whole numbers, follow Associated Press (AP) style: spell out
numbers one through nine, and use numerals for 10 and higher, with numeral-word
combinations for millions, billions, and trillions.

Examples
--------
* There are two ways to build Astropy documentation.
* Follow these 11 steps.
* Measuring astrometry for about 2 billion stars.

For casual expressions, spell out the number.

Example
-------
* A picture is worth a thousand words.

Punctuation
===========

For consistency across Astropy materials, non-U.S. punctuation will be edited
to reflect American punctuation preferences.

**Parentheses**: punctuation belonging to parenthetical material will be placed
inside of closing parentheses, with the exception of commas to denote a small
pause coming after parenthetical material, and periods when parenthetical
material is included within another sentence.

Examples
--------
* (For full contributor guidelines, see our documentation.)
* Once you open a pull request (which should be opened against the ``main``
  branch), please make sure to include the following.
* In some cases, most of the required functionality is contained in a single
  class (or a few classes).

**Quotation marks**: periods and commas will be placed inside of closing
quotation marks, whether double or single.

Examples
--------
* Chief among these terms is the concept of a “coordinate system.”
* Because of the likelihood of confusion between these meanings of “coordinate
  system,” `~astropy.coordinates` avoids this term wherever possible.

**Hyphens vs. En Dashes vs. Em Dashes**

Hyphens (-) should be used for phrasal adjectives and compound words (see
`Hyphenation`_ above).

En dashes (– longer) should be used for number ranges (dates, times, pages) or
to replace the words “to” or “through,” without spaces around the dash.

Examples
--------
* See chapters 14–18.
* We have blocked off March 2019–May 2019 to develop a new version.

Em dashes (— longest) can be used in place of commas, parentheses, or colons to
set off amplifying or explanatory elements. In Astropy materials, follow
Associated Press (AP) style, which calls for spaces on either side of each em
dash.

Examples
--------
* Several types of input angles — array, scalar, tuple, string — can be used in
  the creation of an Angle object.
* The creation of an Angle object supports a variety of input angle types —
  array, scalar, tuple, string, etc.

Spelling
========

For consistency across Astropy materials, non-U.S. spelling will be edited to
reflect American spelling preferences.

Example
-------
* Cross-matching catalog coordinates (versus catalogue)

Time and Date
=============

Use numerals when exact times are expressed. Use the 24-hour system to express
exact times. For consistency across Astropy materials, all instances of exact
times will be edited to reflect 24-hour time system preferences.

Example
-------
* The presentation starts at 15:00.

Express specific dates as numerals in ISO 8601 format, year-month-day.

Example
-------
* Data from the Gaia mission was released on 2018-04-25.

A Note About Voice and Tone
===========================

Across all Astropy materials in narrative sections, please follow these voice
and tone guidelines.

Write in the present tense.

Example
-------
* In the following section, we are going to make a plot...
* To test if your version of ``astropy`` is running correctly...

Use the first-person inclusive plural.

Example
-------
* We did this the long way, but next we can try it the short way...

Use the generic pronoun “you” instead of “one.”

Example
-------
* You can access any of the attributes on a frame by...

Always avoid extraneous or belittling words such as “obviously,” “easily,”
“simply,” “just,” or “straightforward.” Avoid extraneous phrases like, “we just
have to do one more thing.”

Avoid words or phrases that create worry in the mind of the reader. Instead,
use positive language that establishes confidence in the skills being learned.

Examples
--------
* As a best practice...
* One recommended way to...
* An important note to remember is...

Along these lines, use "warning" directives only to note limitations in the
code, not implied limitations in the skills or knowledge of the reader.

Documentation vs. Tutorials vs. Guides
--------------------------------------

Documentation
^^^^^^^^^^^^^
Tone: academic and slightly more formal.

* Use title case capitalization in section headings.
* Do not use contractions.

Tutorials
^^^^^^^^^
Tone: academic but less formal and more friendly.

* Use title case capitalization in introductory/template headings, switch to
  sentence case capitalization for learning/example section headings.
* Section headings should use the imperative mood to form a command or request
  (e.g., “Download the data”).
* Contractions can be used as long as the tense is clear.

Guides
^^^^^^
Tone: academic but less formal and more friendly.

* Use title case capitalization in introductory/template headings, switch to
  sentence case capitalization for learning/example section headings.
* Contractions can be used as long as the tense is clear.

Formatting Guidelines
=====================

Astropy documentation is written in reStructuredText using the Sphinx
documentation generator. When formatting the different sections of your
documentation files, please follow these guidelines to maintain consistency in
section heading hierarchy across Astropy's RST files.

Section headings in reStructuredText files are created by underlining (and
optionally overlining) the section title with a punctuation character the same
length as the text.

Examples
--------

::

  *************************
  This is a Chapter Heading
  *************************

::

  This is a Section Heading
  =========================

Although there are no formally assigned characters to create heading level
hierarchy, as the hierarchy rendering is determined from the succession of
headings, here is a suggested convention to follow when formatting Astropy
documentation files:

# with overline, for parts
* with overline, for chapters
=, for sections
-, for subsections
^, for subsubsections
", for paragraphs

These guidelines follow Sphinx's recommendation in the `Sections
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections>`_
chapter of its reStructuredText Primer and Python's convention in the `7.3.6.
Sections <https://devguide.python.org/documenting/#sections>`_ part of its style
guide.

Other Writing Resources
=======================

Some other resources that may be useful when writing Astropy documentation are:

* Python's `Style Guide
  <https://devguide.python.org/documenting/#style-guide>`_
* Sphinx's `reStructuredText Primer
  <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_
* `Quick reStructuredText
  <https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_