Skip to content

Commit 8bd6c6b

Browse files
author
Quildreen Motta
committed
docs: categories and tips
1 parent 686acb9 commit 8bd6c6b

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

documentation/how-do-i-document-my-code.md

+65-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ through documentation.
1616
## Table of Contents
1717

1818
- [Why do we need documentation?](#why-do-we-need-documentation)
19-
- [Documentation with Meta:Magical](#documentation-with-metamagical)
19+
- [Metadata with Meta:Magical](#metadata-with-metamagical)
2020
- [Social meta-data](#social-meta-data)
2121
- [Execution meta-data](#execution-meta-data)
2222
- [Organisation meta-data](#organisation-meta-data)
2323
- [Usage meta-data](#usage-meta-data)
24+
- [Common categories](#common-categories)
25+
- [How to write documentation](#how-to-write-documentation)
2426

2527

2628
## Why do we need documentation?
@@ -112,7 +114,7 @@ Tower's JavaScript projects. Note that they are not a general approach that can
112114
be applied to any other language, even if the principles can be useful for them.
113115

114116

115-
## Documentation with Meta:Magical
117+
## Metadata with Meta:Magical
116118

117119
Most of the different kinds of documentation described in the previous section
118120
(and more) are attached to JavaScript objects using the
@@ -281,3 +283,64 @@ expect from using that code.
281283
value is an object where the key is the kind of exception thrown, and the
282284
value a description of when it's thrown and why.
283285

286+
287+
### Common categories
288+
289+
A few standard categories to use when describing your objects:
290+
291+
- **Refining**, the function constructs a new object that's similar to some
292+
object provided as argument, but with some new characteristics.
293+
294+
- **Constructing**, the function constructs a new object from scratch.
295+
296+
- **Inspecting**, the function is meant for debugging/runtime reflection.
297+
298+
- **Comparing and testing**, the function allows one to compare different
299+
objects, or test some property in a particular object. `isFoo` functions
300+
always fall in this category.
301+
302+
- **Extracting information**, retrieves part of a compound object.
303+
304+
- **Converting to other types**, allows converting from one type to another
305+
(like `toString`).
306+
307+
- **Transforming**, allows transforming some of the data represented by the
308+
object.
309+
310+
- **Combining**, allows combining different objects to yield a new one.
311+
312+
- **Handling errors**, allows handling errors that may be represented
313+
by/stored in the object.
314+
315+
316+
## How to write documentation
317+
318+
> **TODO**
319+
> This section is a stub and needs to be improved.
320+
321+
Your documentation should look something like:
322+
323+
```text
324+
[short descriptive summary of what the object/message does]
325+
326+
## Why?
327+
328+
[detailed description of WHY the object exists. This should provide
329+
compelling arguments on why someone might use the object.]
330+
331+
## Drawbacks
332+
333+
[if applicable, provide a description of the problems people might
334+
run into by using this object, because of some design trade-off
335+
you made (maybe your API is easy to use and consistent, but not
336+
very efficient? Detail that here)]
337+
338+
## Architecture
339+
340+
[For objects/modules, describe the general architecture, so people
341+
know how each piece fits together, and can better reason about
342+
its behaviour/contribute]
343+
```
344+
345+
Where possible, examples of how to use an object/method/function should be
346+
provided. Examples are great for people to start playing around with.

0 commit comments

Comments
 (0)