Skip to main content

Simple tool to extract high-level documentation from the projects source code

Project description

📑 docthing

Someone once said: "The software is not such if not documented." I do not really remember who but I strongly agree with her/him.

Simple tool to extract high-level documentation from the projects.

Rationale

Documentation is crucial for maintaining a clear understanding of a project's architecture, ensuring that developers and stakeholders can easily comprehend how the system works. Keeping documentation up-to-date with the source code is vital to avoid discrepancies that can lead to confusion and inefficiency. To achieve this, it's essential to keep documentation as close to the code as possible, enabling seamless updates as the code evolves. Additionally, offering multiple levels of documentation, as highlighted by the C4 model, allows different audiences—whether technical experts or non-technical stakeholders—to access the right level of detail, from high-level system overviews to detailed component interactions.

Features

  • 🔧 Highly configurable
  • 📈 Scalable
  • 🏴‍☠️ Language agnostic
  • 🤏 Small fingerprint
  • 🔌 Extensible (Plugins)
  • 🖼️ LOD (Level Of Details: choose the in-depth level of your documentation dynamically)

Table of Contents

Usage

docthing \
    <index-file|project-directory> \
    [--config=<config-file>] \
    [--outdir=<output-directory>]

where:

  • index-file is file in the root of the directory containing the project you want to create documentation for (see Index File section); alternatively this can be the name of the project root which will have to contain a file named docthing.jsonc which will be used as the index-file;
  • config-file is the path, relative to the directory containing the project-index-file, of the configuration file to use for docthing (see Config File section) [default: ./docthing.conf];
  • output-directory is the absolute path to the directory where the documentation output will be produced [default: ./documentation relative to the directory containing the index-file]; if destination does not exsist it will be created.

Index File

The index file is a JSON (eventually with comments) with following structure:

{
    "intro": "<optional path to the introduction file>",
    "quick": "<optional path to the quick start documentation file>",
    "chapter_name": {
        "section_name": "file or directory containing documentation to print",
        [...],
        "section_name": {
            "subsection_name": {...},
            "subsection_name": "file or directory containing documentation",
            [...],
            "subsection_name": [
                "filename 1",
                "filename 2",
                "filename 3"
            ]
        },
        [...]
    },
    "another_section_name": {...},
    [...]
}

Basically the documentation will be splitted into chapters declared by the outmost keys in the JSON file. If an intro key is specified it should be valued with the path to a markdown formatted file containing a brief description of the project. If a quick key is specified it will be used to create a small chapter containing a Quick Start guide for the project and should be valorized with the path pointing to a markdown formatted file containing these instructions (it could be aggo idea to use the README.md file of your project).

PATHS: all paths specified in the index-file should be relative to the file it-self!

The value of each chapter has to be a Documentation Piece which is one of the following:

  • a string containing the path to a source-code file containing the documentation to print;
  • a vector containing the paths to source-code files containing the documentation to print or a Documentation Piece;
  • a dict in the form of a Documentation Piece as value and a string as key.

Each Documentation Piece has the same form as a chapter with the exception that the intro and quick keys are not allowed (actually they are allowed but have no special meaning) and have another special key called __index__ which is a string containing the path to another index-file nested in the project. This is useful to create nested documentation for a project and is encouraged way of structuring the documentation to make it more flexible.

In general the verctor inside a Documentation Piece is discouraged since normally the keys of the dict are used to create the title of a section or subsection and this will not be the case if the vector is used.

Config File

By default the configuration file is assumed to be named docthing.conf and is located in the same directory as the index-file.

The configuration file follows a standard format that supports the use of variables and predefined values. Variables can be referenced using curly braces ({}), and sections are denoted with square brackets ([]). Variables must be defined before being used in the configuration file, and the file is divided into sections with specific purposes. Some settings can be overridden via command-line options.

For more information on the configuration file format, please refer to the documentation.

Documentation options

The documentations options are optional annotations that can be added at the right of the beginning of the documentation section. Newlines are not allowed.

Example:

/* BEGIN FILE DOCUMENTATION (level: 2, user-defined-option: "value")
[markdown-formatted documentation goes here]
END FILE DOCUMENTATION */

The options can be customized by the user but are not mandatory. Some options are provided by default and are described in the next section.

Provided options

  • level: (number): the level of the documentation section. This is a number indicating how in-depth the documentation is. If not specified it will be set to 0 by default. This option is used to choose whether or not to include documentation in the final output based on the selected documentation-level configured in the configuration file or passed via command-line options: it works as an upper bound threshold;

Example: the following documentation will be included in the final output only if the documentation-level is set to 2 or higher:

/* BEGIN FILE DOCUMENTATION (level: 2)
[markdown-formatted documentation goes here]
END FILE DOCUMENTATION */
  • level-only: (boolean): if set to true the documentation will be included in the final output only if the documentation-level configured in the configuration file or passed via command-line options is equal to the level option. Has no effect if not associated with a level option;

Example: the following documentation will be included in the final output only if the documentation-level is set exactly to 2:

/* BEGIN FILE DOCUMENTATION (level: 2, level-only: true)
[markdown-formatted documentation goes here]
END FILE DOCUMENTATION */

Contributing

If you'd like to contribute to the project, please follow these steps:

  • Fork the repository.
  • Create a new branch for your changes.
  • Make your changes and commit them.
  • Push your changes to your fork.
  • Create a pull request to the main repository.

License

See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docthing-0.0.2.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

docthing-0.0.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file docthing-0.0.2.tar.gz.

File metadata

  • Download URL: docthing-0.0.2.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for docthing-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2b30a4598f0020df9bbef77e5e7fe80b9b7c048c59a1a7866e7119fd0c4b332d
MD5 eb26a68cf556532ee2a8504657c63335
BLAKE2b-256 a50c438c15d3ea7ab25c1ca5b6c2093de11e0157e7af4bb508dcf58b11598cec

See more details on using hashes here.

File details

Details for the file docthing-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: docthing-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for docthing-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d34dc3424f2c6f528c4c8abe60d20a733866c9c672f66c530a4b880bb4ecaaae
MD5 b87503e1af60071819645ac33e809803
BLAKE2b-256 51ce6e0193ed2655a54ad48ba826496d7798bf9cb01f3ad47ab2decde590842f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page