zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.49k stars 6.42k forks source link

Modularisation and Restructuring of Documentation #33725

Closed nashif closed 2 years ago

nashif commented 3 years ago

Is your enhancement proposal related to a problem? Please describe. The Zephyr documentation currently is composed of different sources all tied together through one single and long build process that collects data from the different sources, coverts the information into the final format and links everything into what we get on docs.zephyrproject.org.

The whole process is very long and on some machines can take up to 15-20 minutes, basically building everything we have, including:

Right now it is either you build the whole thing or nothing. Some steps were taken to reduce the time by skipping the generation of lengthy reference pages (Kconfig), but things are still very slow.

Another limitation is related to the fact that we are not able to publish or build a subset of the documentation for different use cases. For example, to build a printable reference of Zephyr in PDF we would have to include everything that we have on the online version and there is no way to control how things are structured and what information end up in such a reference. If you are using the Zephyr documentation to support a product, you might be interested in including only the sections of the documentation relevant to your product, supported subsystems and hardware and not documentation of all samples and boards that come with Zephyr.

For Zephyr itself, there is a desire to produce documentation for only a subset of the features and be selective about what ends up in the final document, this requires a well structured documentation layout in general and a well defined and controlled content to allow for extraction of information without breaking cross-references and linkage.

Describe the solution you'd like

Through configuration options it should then be possible to select any of the above to create the desired output, but it should also be possible to filter content of each chapter if it makes sense, for example, limit the board reference to a certain vendor, or filter out samples that are not relevant to the mode of output.

The above could be done in one single documentation instance, but could also be done in multiple instance that are linked together using the current doc build system. This would also improve the build speed and eventually would allow building documentation parallel (?)

nashif commented 3 years ago

@kestewart FYI

nashif commented 2 years ago

Throwing this in to get started and kick off the shuffling, covers a subset only, so feel free to add anything you think is missing, whether in chapter form or sub sections...

gmarull commented 2 years ago

I've been doing some quick hacks to the toctree and I think a layout similar to the one shown in the picture would make things easier fort both newcomers and experienced developers:

image

As you may notice, there are many missing parts, but I hope it shows the idea:

This approach is somehow inspired by https://docs.godotengine.org/en/latest/index.html (not new, I like these docs :smile:)

nashif commented 2 years ago
  • "Topics" would expose at top-level areas such as sensors, power management, connectivity (/bluetooth), fieldbus (/canbus, /modbus...), Kernel, etc. These areas would include inside: guides, API, examples, etc. The motivation: if I'm interested in a particular topic, e.g. sensors, I should have everything under topics/sensor: the API reference, how do I create a driver, examples, etc.

"Topics" is very general, what is the criteria for something to land under Topics? Based on the example you provide this could grow into a large number of topics that are in fact sub-topics, i.e. I do not see why pinctrl or fieldbus needs to be a top level topic and not part of something more general (i.e. hardware support or something else) with those being sub-topics instead.

  • Create multiple toctrees, each being kind of orthogonal to others

Can you elaborate on this a bit more?

gmarull commented 2 years ago
  • "Topics" would expose at top-level areas such as sensors, power management, connectivity (/bluetooth), fieldbus (/canbus, /modbus...), Kernel, etc. These areas would include inside: guides, API, examples, etc. The motivation: if I'm interested in a particular topic, e.g. sensors, I should have everything under topics/sensor: the API reference, how do I create a driver, examples, etc.

"Topics" is very general, what is the criteria for something to land under Topics? Based on the example you provide this could grow into a large number of topics that are in fact sub-topics, i.e. I do not see why pinctrl or fieldbus needs to be a top level topic and not part of something more general (i.e. hardware support or something else) with those being sub-topics instead.

I didn't have better ideas, but I agree Topics is not a great name. What is a topic or a sub-topic is really subjective, so there's no single answer here. I think the idea would be to expose at top-level common or popular areas, e.g. sensors, Kernel or Devicetree may deserve a top-level entry whereas Fieldbus could be under protocols, industrial, or communications areas. I was thinking on a range of ~20-25 top-level topics.

  • Create multiple toctrees, each being kind of orthogonal to others

Can you elaborate on this a bit more?

If you look at the screenshot you have in purple "GENERAL", "TOPICS", etc. These are the different toctree titles, IMO they create a clear content split. We now have 2: "CONTENTS" (everything) and "REFERENCE" (API docs, Kconfig, DT bindings).

nashif commented 2 years ago

If you look at the screenshot you have in purple "GENERAL", "TOPICS", etc. These are the different toctree titles, IMO they create a clear content split. We now have 2: "CONTENTS" (everything) and "REFERENCE" (API docs, Kconfig, DT bindings).

ok, thanks. this looks good and we should consider it IMO

carlescufi commented 2 years ago

API meeting:

mbolivar-nordic commented 2 years ago

Here is my suggested top level tree. It includes a few changes from @nashif 's. For convenience, here is a diff from his proposal to mine: https://gist.github.com/mbolivar-nordic/55081101a53641cfed2555d01220ff63

carlescufi commented 2 years ago

@mbolivar-nordic, I do like your proposal, but I have a few questions:

  1. Where is the Application Development section?
  2. Why that "Tutorials" section with Kconfig and DT when we already have entries for those under "Build and Configuration System"?
  3. Why a separate "APIs" top-level entry?
gmarull commented 2 years ago

Another tentative toctree. Not all sections may be correct, the general idea is to expose more content (make root toctree longer). Many content is hard to discover now because it is deeply buried in the toctree. It's hard to do since I'm still discovering new content...


INTRODUCTION
------------

* About Zephyr
* Getting Started
  - GSG
  - Beyond GSG
  - Basic samples
* Supported Boards
  - ARM
    - ...

REFERENCE
---------

/* A section with reference guides (including APIs, related samples in each section) */

* Build System
* Devicetree
* Kconfig
* Kernel
* Connectivity
  - Networking
  - Bluetooth
* Peripheral drivers
  - ADC
    - API description, usecases, implementation guidelines, etc.
    - Supported hardware (include table with DT compatibles?)
    - Samples
  - GPIO
  - ...
* OS Services
  - File systems
  - Logging
  - Tracing
  - ...
* Testing
...

DEVELOPMENT
-----------

/* A section related to day-to-day development */

* Applications
  - Example Application (?)
* IDE Support
  - VSCode
  - PlatformIO
  - ...
* Coding Standards
  - Styleguide
  - Rules
* Documentation
  - Howto
  - Guidelines (rst/Doxygen)
  ...
* Tools
  - Coccinelle
  - clang-format
  ...

COMMUNITY
---------

* Contributing
* Communication channels
* Organization
  - TSC Project Roles
  - Release Process
  ...
* Example projects
  - Projects using Zephyr (?)

OTHERS
------

/* Useful shortcuts, used as reference */

* API Pages (Doxygen)
* Kconfig Options
* Devicetree Bindings
* Terminology
  - Glossary
  - Environment Variables

Other points I'd like to discuss:

mbolivar-nordic commented 2 years ago

Good question. I guess it's missing from @nashif's proposal as well, so I am sure he will have his own answer for this question. Probably we should add it back, although looking at it again I think some of the content would be better off elsewhere in the docs.

  • Why that "Tutorials" section with Kconfig and DT when we already have entries for those under "Build and Configuration System"?

This is part of a long term plan I have that relies on cross-platform QEMU support as part of @stephanosio 's new SDKs for macOS and Windows having all the host tools.

Basically I think we should add quick tutorials that cover simple modifications to hello_world that treat the basic things.

So for Kconfig, the tutorial would look like this:

Then you tell people that drivers and subsystems each have kconfig options they can turn on, and other values like integers and strings that they can use to set similar macros. This would give people better intuition for Kconfig if they don't have a Linux background than our current documentation IMO.

Then do something similar for devicetree, showing people how to

That in turn enables other documentation improvements like:

  • Why a separate "APIs" top-level entry?

Where else are we going to document the [ other APIs mentioned in "API Overview" not already covered elsewhere ]?

mbolivar-nordic commented 2 years ago

I am thinking we need:

  1. a machine-readable index of SoCs (map from SoC names to metadata, like what DTSI files are associated with the SoC)
  2. a machine-readable index of device drivers that implement particular APIs (map from APIs to lists of drivers; each driver in the list is a map from a name to driver metadata; driver metadata is things like the Kconfig option to enable the driver and any devicetree compatibles it enables

Then we can add some sphinx scripting to make the documentation generated from this info in a nice way.

I've been sketching around and have a proposal like this for SoCs:

───────┬───────────────────────────────────────────────
       │ File: soc/arm/nordic_nrf/socs.yaml
───────┼───────────────────────────────────────────────
   1   │ # supported nRF SoCs; repeat for other vendors
   2   │ 
   3   │ nRF51822:
   4   │   dtsis:
   5   │     - nordic/nrf51822_qfaa.dtsi
   6   │     - nordic/nrf51822_qfac.dtsi
   7   │ nRF52805:
   8   │   dtsis: [nordic/nrf52805_caaa.dtsi]
   9   │ nRF52810:
  10   │   dtsis: [nordic/nrf52810_qfaa.dtsi]
  11   │ nRF52811:
  12   │   dtsis: [nordic/nrf52811_qfaa.dtsi]
  13   │ nRF52820:
  14   │   dtsis: [nordic/nrf52820_qdaa.dtsi]
  15   │ nRF52832:
  16   │   dtsis: [nordic/nrf52832_qfaa.dtsi]
  17   │ nRF52833:
  18   │   dtsis: [nordic/nrf52833_qiaa.dtsi]
  19   │ nRF52840:
  20   │   dtsis: [nordic/nrf52840_qiaa.dtsi]
  21   │ nRF5340:
  22   │   dtsis:
  23   │     - nordic/nrf5340_cpuappns_qkaa.dtsi
  24   │     - nordic/nrf5340_cpuapp_qkaa.dtsi
  25   │     - nordic/nrf5340_cpunet_qkaa.dtsi
  26   │ nRF9160:
  27   │   dtsis:
  28   │     - nordic/nrf9160ns_sica.dtsi
  29   │     - nordic/nrf9160_sica.dtsi
───────┴───────────────────────────────────────────────

We could do similarly for drivers. Thoughts?

nashif commented 2 years ago

Closing, as the bulk of the proposed changes has been done and is merged.