xref: /aosp_15_r20/external/pigweed/seed/0102.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _seed-0102:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker=====================================
4*61c4878aSAndroid Build Coastguard Worker0102: Consistent Module Documentation
5*61c4878aSAndroid Build Coastguard Worker=====================================
6*61c4878aSAndroid Build Coastguard Worker.. seed::
7*61c4878aSAndroid Build Coastguard Worker   :number: 102
8*61c4878aSAndroid Build Coastguard Worker   :name: Consistent Module Documentation
9*61c4878aSAndroid Build Coastguard Worker   :status: Accepted
10*61c4878aSAndroid Build Coastguard Worker   :proposal_date: 2023-02-10
11*61c4878aSAndroid Build Coastguard Worker   :cl: 128811, 130410
12*61c4878aSAndroid Build Coastguard Worker   :authors: Chad Norvell
13*61c4878aSAndroid Build Coastguard Worker   :facilitator: Kayce Basques
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Worker---------------------
16*61c4878aSAndroid Build Coastguard WorkerStatus (October 2023)
17*61c4878aSAndroid Build Coastguard Worker---------------------
18*61c4878aSAndroid Build Coastguard WorkerIf you're looking for guidelines on how to author module docs, use these:
19*61c4878aSAndroid Build Coastguard Worker:ref:`docs-contrib-docs-modules`
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Worker.. caution::
22*61c4878aSAndroid Build Coastguard Worker
23*61c4878aSAndroid Build Coastguard Worker   SEED-0102 is still considered accepted because we are still using some parts
24*61c4878aSAndroid Build Coastguard Worker   of it in our current module docs guidelines. However, over the course of
25*61c4878aSAndroid Build Coastguard Worker   2023 we discovered that other parts of the SEED-0102 plan didn't achieve our
26*61c4878aSAndroid Build Coastguard Worker   goals. Therefore, at this point you should only read SEED-0102 for historical
27*61c4878aSAndroid Build Coastguard Worker   context on how our docs guidelines have evolved.
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Worker-------
30*61c4878aSAndroid Build Coastguard WorkerSummary
31*61c4878aSAndroid Build Coastguard Worker-------
32*61c4878aSAndroid Build Coastguard WorkerPigweed modules ought to have documentation that is reasonably comprehensive,
33*61c4878aSAndroid Build Coastguard Workerthat has a consistent and predictable format, and that provides the reader with
34*61c4878aSAndroid Build Coastguard Workersufficient information to judge whether using the module is the right choice for
35*61c4878aSAndroid Build Coastguard Workerthem. This SEED proposes a documentation philosophy applicable to all Pigweed
36*61c4878aSAndroid Build Coastguard Workermodules and a flexible yet consistent structure to which all module docs should
37*61c4878aSAndroid Build Coastguard Workerconform.
38*61c4878aSAndroid Build Coastguard Worker
39*61c4878aSAndroid Build Coastguard WorkerDefinitions
40*61c4878aSAndroid Build Coastguard Worker-----------
41*61c4878aSAndroid Build Coastguard WorkerIn this SEED, we define *users* as developers using Pigweed in downstream
42*61c4878aSAndroid Build Coastguard Workerprojects, and *maintainers* as developers working on upstream Pigweed. The
43*61c4878aSAndroid Build Coastguard Workerprimary focus of this SEED is to improve the documentation experience for users.
44*61c4878aSAndroid Build Coastguard Worker
45*61c4878aSAndroid Build Coastguard Worker----------
46*61c4878aSAndroid Build Coastguard WorkerMotivation
47*61c4878aSAndroid Build Coastguard Worker----------
48*61c4878aSAndroid Build Coastguard WorkerCurrently, each Pigweed module is required to have, at minimum, a single
49*61c4878aSAndroid Build Coastguard Worker``docs.rst`` file that contains the module's documentation. This gives the
50*61c4878aSAndroid Build Coastguard Workermodule maintainer considerable discretion to provide as much or as little
51*61c4878aSAndroid Build Coastguard Workerdocumentation as they would like. However, this approach fails for Pigweed
52*61c4878aSAndroid Build Coastguard Workermaintainers by providing no guidance or structure to help them write effective
53*61c4878aSAndroid Build Coastguard Workerdocumentation, and certainly fails Pigweed users who struggle to find the
54*61c4878aSAndroid Build Coastguard Workerinformation they're looking for. So a solution needs to make it easier for
55*61c4878aSAndroid Build Coastguard WorkerPigweed maintainers to write good documentation, thereby making Pigweed much
56*61c4878aSAndroid Build Coastguard Workermore accessible to its users.
57*61c4878aSAndroid Build Coastguard Worker
58*61c4878aSAndroid Build Coastguard WorkerPigweed's design is inherently and intentionally modular. So documentation at
59*61c4878aSAndroid Build Coastguard Workerthe level of the *module* is the most natural place to make impactful
60*61c4878aSAndroid Build Coastguard Workerimprovements, while avoiding a fundamental restructuring of the Pigweed
61*61c4878aSAndroid Build Coastguard Workerdocumentation. Module docs are also what the majority of Pigweed users rely on
62*61c4878aSAndroid Build Coastguard Workermost. As a result, this SEED is focused exclusively on improving module
63*61c4878aSAndroid Build Coastguard Workerdocumentation.
64*61c4878aSAndroid Build Coastguard Worker
65*61c4878aSAndroid Build Coastguard Worker`Diátaxis <https://diataxis.fr/>`_ proposes a four-mode framework for technical
66*61c4878aSAndroid Build Coastguard Workerdocumentation, illustrated below with terminology altered to better match
67*61c4878aSAndroid Build Coastguard WorkerPigweed's needs:
68*61c4878aSAndroid Build Coastguard Worker
69*61c4878aSAndroid Build Coastguard Worker.. csv-table::
70*61c4878aSAndroid Build Coastguard Worker   :widths: 10, 20, 20
71*61c4878aSAndroid Build Coastguard Worker
72*61c4878aSAndroid Build Coastguard Worker   , "**Serve our study**", "**Serve our work**"
73*61c4878aSAndroid Build Coastguard Worker   "**Practical steps**", "Tutorials (`learning-oriented <https://diataxis.fr/tutorials/>`_)", "Guides (`task-oriented <https://diataxis.fr/how-to-guides/>`_)"
74*61c4878aSAndroid Build Coastguard Worker   "**Theoretical knowledge**", "Concept & design docs (`understanding-oriented <https://diataxis.fr/explanation/>`_)", "Interface reference (`information-oriented <https://diataxis.fr/reference/>`_)"
75*61c4878aSAndroid Build Coastguard Worker
76*61c4878aSAndroid Build Coastguard WorkerPigweed needs a framework that ensures modules have coverage across these four
77*61c4878aSAndroid Build Coastguard Workerquadrants. That framework should provide a structure that makes it easier for
78*61c4878aSAndroid Build Coastguard Workermaintainers to write effective documentation, and a single page that provides
79*61c4878aSAndroid Build Coastguard Workerthe most basic information a user needs to understand the module.
80*61c4878aSAndroid Build Coastguard Worker
81*61c4878aSAndroid Build Coastguard WorkerAlternatives
82*61c4878aSAndroid Build Coastguard Worker------------
83*61c4878aSAndroid Build Coastguard WorkerThere are risks to focusing on module docs:
84*61c4878aSAndroid Build Coastguard Worker
85*61c4878aSAndroid Build Coastguard Worker* The most useful docs are those that focus on tasks rather than system
86*61c4878aSAndroid Build Coastguard Worker  features. The module-focused approach risks producing feature-focused docs
87*61c4878aSAndroid Build Coastguard Worker  rather than task-focused docs, since the tasks users need to complete may not
88*61c4878aSAndroid Build Coastguard Worker  fit within the boundaries of a module.
89*61c4878aSAndroid Build Coastguard Worker
90*61c4878aSAndroid Build Coastguard Worker* Likewise, focusing on module documentation reduces focus on content that
91*61c4878aSAndroid Build Coastguard Worker  integrates across multiple modules.
92*61c4878aSAndroid Build Coastguard Worker
93*61c4878aSAndroid Build Coastguard WorkerThe justification for focusing on module documentation doesn't imply that module
94*61c4878aSAndroid Build Coastguard Workerdocs are the *only* docs that matter. Higher level introductory and guidance
95*61c4878aSAndroid Build Coastguard Workermaterial that integrates Pigweed as a system and covers cross cutting concerns
96*61c4878aSAndroid Build Coastguard Workeris also important, and would arguably be more effective at bringing new
97*61c4878aSAndroid Build Coastguard Workerdevelopers into the Pigweed ecosystem. However, this SEED proposes focusing on
98*61c4878aSAndroid Build Coastguard Workermodule docs for two primary reasons:
99*61c4878aSAndroid Build Coastguard Worker
100*61c4878aSAndroid Build Coastguard Worker1. Improving module docs and providing them with a consistent structure will
101*61c4878aSAndroid Build Coastguard Worker   have the largest impact with the least amount of investment.
102*61c4878aSAndroid Build Coastguard Worker
103*61c4878aSAndroid Build Coastguard Worker2. It will be easier to construct higher-level and cross-cutting documentation
104*61c4878aSAndroid Build Coastguard Worker   from well-developed module docs compared to going the other direction.
105*61c4878aSAndroid Build Coastguard Worker
106*61c4878aSAndroid Build Coastguard WorkerWhile not a primary consideration, a bonus of a module-focused approach is that
107*61c4878aSAndroid Build Coastguard Workermodules already have owners, and those owners are natural candidates to be the
108*61c4878aSAndroid Build Coastguard Workermaintainers of their modules' docs.
109*61c4878aSAndroid Build Coastguard Worker
110*61c4878aSAndroid Build Coastguard Worker--------
111*61c4878aSAndroid Build Coastguard WorkerProposal
112*61c4878aSAndroid Build Coastguard Worker--------
113*61c4878aSAndroid Build Coastguard WorkerThis change would require each module directory to match this structure::
114*61c4878aSAndroid Build Coastguard Worker
115*61c4878aSAndroid Build Coastguard Worker  module root directory/
116*61c4878aSAndroid Build Coastguard Worker  ├── docs.rst
117*61c4878aSAndroid Build Coastguard Worker  ├── concepts.rst [or concepts/...] [when needed]
118*61c4878aSAndroid Build Coastguard Worker  ├── design.rst [or design/...] [when needed]
119*61c4878aSAndroid Build Coastguard Worker  ├── guides.rst [or guides/...] [when needed]
120*61c4878aSAndroid Build Coastguard Worker121*61c4878aSAndroid Build Coastguard Worker  ├── tutorials/ [aspirational]
122*61c4878aSAndroid Build Coastguard Worker  │   ├── index.rst
123*61c4878aSAndroid Build Coastguard Worker  │   └── ...
124*61c4878aSAndroid Build Coastguard Worker125*61c4878aSAndroid Build Coastguard Worker  ├── api.rst [or api/...] [if applicable]
126*61c4878aSAndroid Build Coastguard Worker  ├── cli.rst [if applicable]
127*61c4878aSAndroid Build Coastguard Worker  └── gui.rst [if applicable]
128*61c4878aSAndroid Build Coastguard Worker
129*61c4878aSAndroid Build Coastguard WorkerFundamental module docs
130*61c4878aSAndroid Build Coastguard Worker-----------------------
131*61c4878aSAndroid Build Coastguard WorkerThese three documents are the minimum required of every Pigweed module.
132*61c4878aSAndroid Build Coastguard Worker
133*61c4878aSAndroid Build Coastguard WorkerThe basics: ``docs.rst``
134*61c4878aSAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^^
135*61c4878aSAndroid Build Coastguard WorkerBasic, structured information about the module, including what it does, what
136*61c4878aSAndroid Build Coastguard Workerproblems it's designed solve, and information that lets a user quickly evaluate
137*61c4878aSAndroid Build Coastguard Workerif the module is useful to them.
138*61c4878aSAndroid Build Coastguard Worker
139*61c4878aSAndroid Build Coastguard WorkerHow it works and why: ``design.rst`` & ``concepts.rst`` (understanding-oriented)
140*61c4878aSAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141*61c4878aSAndroid Build Coastguard WorkerBackground on the design goals, assumptions, limitations, and implementation
142*61c4878aSAndroid Build Coastguard Workerdetails of a module, and may contrast the design of the module with alternative
143*61c4878aSAndroid Build Coastguard Workersolutions.
144*61c4878aSAndroid Build Coastguard Worker
145*61c4878aSAndroid Build Coastguard WorkerThis content can start in the "Design considerations" section of the index, and
146*61c4878aSAndroid Build Coastguard Workergrow into this separate document as the module matures. If that document becomes
147*61c4878aSAndroid Build Coastguard Workertoo large, the single ``design.rst`` file can be replaced by a ``design``
148*61c4878aSAndroid Build Coastguard Workersubdirectory containing more than one nested doc.
149*61c4878aSAndroid Build Coastguard Worker
150*61c4878aSAndroid Build Coastguard WorkerSome modules may need documentation on fundamental concepts that are independent
151*61c4878aSAndroid Build Coastguard Workerof the module's solution. For example, a module that provides a reliable
152*61c4878aSAndroid Build Coastguard Workertransport layer may include a conceptual description of reliable transport in
153*61c4878aSAndroid Build Coastguard Workergeneral in a ``concepts.rst`` file or ``concepts`` subdirectory.
154*61c4878aSAndroid Build Coastguard Worker
155*61c4878aSAndroid Build Coastguard WorkerHow to get stuff done: ``guides.rst`` (task-oriented)
156*61c4878aSAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157*61c4878aSAndroid Build Coastguard WorkerThese are focused on specific outcomes and should be produced as soon as we see
158*61c4878aSAndroid Build Coastguard Workera question being answered multiple times. Each module should have at least one
159*61c4878aSAndroid Build Coastguard Workerguide on integrating the module into a project, and one guide on the most common
160*61c4878aSAndroid Build Coastguard Workeruse case.
161*61c4878aSAndroid Build Coastguard Worker
162*61c4878aSAndroid Build Coastguard WorkerThis content can start in the "Getting started" section of the index, and grow
163*61c4878aSAndroid Build Coastguard Workerinto this separate document as the module matures. If that document becomes too
164*61c4878aSAndroid Build Coastguard Workerlarge, it can be replaced with a ``guides`` subdirectory containing more than
165*61c4878aSAndroid Build Coastguard Workerone doc.
166*61c4878aSAndroid Build Coastguard Worker
167*61c4878aSAndroid Build Coastguard WorkerInterface docs (information-oriented)
168*61c4878aSAndroid Build Coastguard Worker-------------------------------------
169*61c4878aSAndroid Build Coastguard WorkerThese docs describe the module's interfaces. Each of these docs may be omitted
170*61c4878aSAndroid Build Coastguard Workerif the module doesn't include an applicable interface.
171*61c4878aSAndroid Build Coastguard Worker
172*61c4878aSAndroid Build Coastguard Worker``api.rst``: External API reference
173*61c4878aSAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174*61c4878aSAndroid Build Coastguard WorkerModules should have reference documentation for their user-facing APIs. Modules
175*61c4878aSAndroid Build Coastguard Workerthat have APIs for multiple languages should replace the single ``api.rst`` with
176*61c4878aSAndroid Build Coastguard Workeran ``api`` subdirectory with docs for each supported language.
177*61c4878aSAndroid Build Coastguard Worker
178*61c4878aSAndroid Build Coastguard WorkerHow API docs should be structured, generated, and maintained is a complex topic
179*61c4878aSAndroid Build Coastguard Workerthat this SEED will not determine.
180*61c4878aSAndroid Build Coastguard Worker
181*61c4878aSAndroid Build Coastguard Worker``cli.rst`` & ``gui.rst``: Developer tools reference
182*61c4878aSAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183*61c4878aSAndroid Build Coastguard WorkerA user-facing command line interface (CLI) should be documented in ``cli.rst``
184*61c4878aSAndroid Build Coastguard Workerif the module provides one. It's ideal if this documentation closely matches the
185*61c4878aSAndroid Build Coastguard Workeroutput of the CLI tool's "help" command.
186*61c4878aSAndroid Build Coastguard Worker
187*61c4878aSAndroid Build Coastguard WorkerIf the module provides a graphical user interface (GUI) (including text mode
188*61c4878aSAndroid Build Coastguard Workerinterfaces and web front-ends), its documentation should be included in
189*61c4878aSAndroid Build Coastguard Worker``gui.rst``.
190*61c4878aSAndroid Build Coastguard Worker
191*61c4878aSAndroid Build Coastguard WorkerTutorials (learning-oriented)
192*61c4878aSAndroid Build Coastguard Worker-----------------------------
193*61c4878aSAndroid Build Coastguard WorkerWe keep these as separate files in ``tutorials``. These take considerable effort
194*61c4878aSAndroid Build Coastguard Workerto develop, so they aren't *required*, but we aspire to develop them for all but
195*61c4878aSAndroid Build Coastguard Workerthe most trivial modules.
196*61c4878aSAndroid Build Coastguard Worker
197*61c4878aSAndroid Build Coastguard WorkerWhen one size does not fit all
198*61c4878aSAndroid Build Coastguard Worker------------------------------
199*61c4878aSAndroid Build Coastguard WorkerPigweed modules span a spectrum of complexity, from relatively simple embedded
200*61c4878aSAndroid Build Coastguard Workerlibraries to sophisticated communication protocols and host-side developer
201*61c4878aSAndroid Build Coastguard Workertooling. The structure described above should be the starting point for each
202*61c4878aSAndroid Build Coastguard Workermodule's documentation and should be appropriate to the vast majority of
203*61c4878aSAndroid Build Coastguard Workermodules. But this proposal is not strictly prescriptive; modules with
204*61c4878aSAndroid Build Coastguard Workerdocumentation needs that are not met by this structure are free to deviate from
205*61c4878aSAndroid Build Coastguard Workerit by *adding* docs that are not mentioned here.
206*61c4878aSAndroid Build Coastguard Worker
207*61c4878aSAndroid Build Coastguard WorkerExamples
208*61c4878aSAndroid Build Coastguard Worker--------
209*61c4878aSAndroid Build Coastguard WorkerA template for implementing this structure can be found ``docs/templates/docs``.
210