========================= Official MxOS Style Guide ========================= ----------------------------------------------------- Writing Standards and Conventions in reStructuredText ----------------------------------------------------- :Authors: - Rénich Bon Ćirić :Organization: Fundación MxOS, A.C. :Date: September 2026 :Status: Active Standard Purpose and Scope ================= This document establishes the official formatting, markup, and technical writing guidelines in **reStructuredText** for all Fundación MxOS projects, repositories, and publications. The objective is to ensure maximum readability, stylistic consistency, and cross-platform compatibility across rendering engines such as **Docutils**, **Sphinx**, and Git forge web viewers such as Forgejo or GitLab. Fundamentals: Docutils and Sphinx ================================= MxOS technical documentation is built upon the standard architecture of the Python and Linux ecosystem: * **Docutils**: The core processing engine and base specification for ``.rst`` files. It parses the fundamental syntax, builds the abstract syntax tree, and converts plain text into structured formats such as HTML, LaTeX, and manpages. * **Sphinx**: The technical documentation generator framework built on top of Docutils. It extends the base syntax with advanced directives, thematic index management, typed cross-references, syntax highlighting with Pygments, and gettext internationalization. Cross-Platform Rendering Differences ------------------------------------ Although the core syntax is shared, platforms such as Forgejo or GitHub process ``.rst`` files using native Docutils parsers or intermediate libraries, whereas the official web portal `docs.mx-os.mx` is built with Sphinx. .. note:: All documentation must be valid under both the baseline Docutils standard and Sphinx. Syntax must be verified locally using the ``rstcheck`` tool before committing. .. caution:: **Incompatibility of the contents Directive with the Furo Theme**: Do not include the ``.. contents::`` directive in documents intended for the Sphinx portal `docs.mx-os.mx`. The Furo theme automatically generates the table of contents in the right sidebar; the explicit presence of ``.. contents::`` is intercepted by Furo and rendered as a visual critical error block. Heading Structure and Hierarchy =============================== The heading hierarchy must follow a strict and predictable sequence. Skipping levels in the structural hierarchy is prohibited. .. list-table:: :header-rows: 1 :widths: 15 35 50 * - Level - Adornment - Standard Usage * - **Main Title** - Overlined and underlined with ``=`` - Single title of the document or page. * - **Subtitle** - Overlined and underlined with ``-`` - Descriptive subtitle immediately following the title. * - **H1 Section** - Underlined with ``=`` - Major divisions of the document. * - **H2 Section** - Underlined with ``-`` - Thematic subsections. * - **H3 Section** - Underlined with ``^`` - Specific breakdowns of a subsection. * - **H4 Section** - Underlined with ``"`` - Analytical elements or minor points. Strict Underline Length Rule ---------------------------- The length of adornment lines **must match the exact character count of the heading text**. If the underline is shorter or longer than the heading, strict RST parsers will emit warnings and continuous integration tools such as ``rstcheck`` will fail validation: .. code-block:: rst =================== Título Correcto RST =================== Sección de Primer Nivel ======================= Subsección de Segundo Nivel --------------------------- Spacing and Indentation Rules ============================= Institutional 3-Space Indentation --------------------------------- At Fundación MxOS, subordinate content inside RST directives such as admonition blocks, table options, or definition list items **must use a uniform 3-space indentation**: .. code-block:: rst .. note:: Este bloque utiliza exactamente 3 espacios de indentación respecto al margen izquierdo de la directiva. Mandatory Blank Lines --------------------- To prevent RST parsers from collapsing paragraphs or interpreting directives as literal plain text, inserting a blank line is mandatory: * Before and after any directive such as ``.. code-block::``, ``.. note::``, or ``.. toctree::``. * Before starting a bulleted or numbered list that follows a paragraph. * **Between a parent list item and a nested sublist**. Without a blank line preceding the sublist, Sphinx collapses the nested items into the parent item's paragraph in the rendered HTML. .. code-block:: rst * Elemento principal de lista * Elemento anidado (la línea en blanco previa es obligatoria) * Segundo elemento anidado * Siguiente elemento principal Zero-Spaces Around Forward Slashes Rule --------------------------------------- Across all MxOS technical documentation, **never use spaces around forward slashes**. Always write ``term/term``, never ``term / term``: * **Correct**: ``offline/air-gapped``, ``QEMU/KVM``, ``ansible/koji``, ``mkosi/kiwi``, ``and/or``. * **Incorrect**: ``offline / air-gapped``, ``QEMU / KVM``, ``ansible / koji``, ``mkosi / kiwi``, ``and / or``. Code Blocks and Syntax Highlighting =================================== To include code snippets, configuration files, or terminal commands, use the ``.. code-block::`` directive and mandatorily specify the syntax language: .. code-block:: rst .. code-block:: bash #!/usr/bin/bash set -euo pipefail echo "Despliegue automatizado de Koji Hub" Code Block Guidelines --------------------- * **Supported Languages**: ``bash``, ``spec``, ``python``, ``crystal``, ``c``, ``cpp``, ``zig``, ``yaml``, ``json``, ``ini``, ``rst``, ``text``. * **Prohibition of :caption:**: Do not use the ``:caption:`` option inside code blocks in order to preserve uniform compatibility between plain Docutils and custom Sphinx themes. * **Generic Literal Blocks**: For uncolored terminal output or unformatted ASCII text, you may use the double-colon marker ``::`` followed by a blank line and 3-space indentation: :: +---------------------------------------------+ | Topología de Red: Servidor Koji Hub | | IP: 192.168.122.10/24 - VLAN: 100 | +---------------------------------------------+ Data Tables =========== Technical documentation uses two main types of tables depending on the structural complexity of the data. Simple Tables ------------- Recommended for brief comparisons and single-line attribute lists: .. code-block:: rst ================= ================= =================================== Componente Paquete RPM Función Principal ================= ================= =================================== Koji Hub koji-hub Servicio web XML-RPC central Koji Builder koji-builder Daemon de compilación Mock Sigul Client sigul Firma remota de paquetes RPM ================= ================= =================================== Grid Tables ----------- Recommended for complex matrices with multi-line cells, code blocks, or hierarchical structures: .. code-block:: rst +-------------------+--------------------+--------------------------------+ | Parámetro | Tipo de Dato | Descripción Técnica | +===================+====================+================================+ | ``--buildsrpm`` | Booleano | Empaqueta fuentes y spec sin | | | | ejecutar compilación binaria. | +-------------------+--------------------+--------------------------------+ | ``--rebuild`` | Ruta (String) | Ejecuta compilación binaria | | | | completa dentro del chroot. | +-------------------+--------------------+--------------------------------+ Hyperlinks and Cross-References =============================== External Links -------------- To link to web resources, use the link syntax with visible text: .. code-block:: rst `Repositorio de CentOS Stream 10 `_ To keep the text clean in long documents, defining link targets at the end of the document is recommended: .. code-block:: rst Consulte la documentación oficial de `Koji Project`_ y de `Fedora Packaging`_. .. Referencias Externas .. _Koji Project: https://koji.fedoraproject.org/koji/ .. _Fedora Packaging: https://docs.fedoraproject.org/en-US/packaging-guidelines/ Internal References and Anchors ------------------------------- To navigate between sections of the same document or across pages of the Sphinx portal: 1. **Define an anchor before the heading**: .. code-block:: none .. _seccion-bootstrap: Procedimiento de Bootstrap ========================== 2. **Link to the anchor**: .. code-block:: none Consulte el :ref:`seccion-bootstrap` para inicializar el chroot. Admonitions =========== Admonition directives highlight relevant information for the operator according to its level of technical criticality: .. list-table:: :header-rows: 1 :widths: 25 75 * - Directive - Operational Use Case * - ``.. note::`` - Contextual information, design details, or methodological clarifications. * - ``.. tip::`` - Performance recommendations, keyboard shortcuts, or best practices. * - ``.. important::`` - Indispensable requirements or mandatory steps for the success of a task. * - ``.. warning::`` - Warnings about potential build failures, broken dependencies, or incompatibilities. * - ``.. caution::`` - Severe risks of data loss, repository corruption, or production misconfiguration. Usage Example: .. code-block:: rst .. caution:: No ejecute ``git push --force`` sin especificar el commit base esperado; podría sobrescribir el trabajo concurrente de otros mantenedores. Internal Comments ================= Comments are technical notes intended for file editors that are not rendered in the HTML or PDF output. They are defined by prefixing two dots and a space: .. code-block:: rst .. TODO: Actualizar esta sección cuando Koji 1.35 esté disponible en EPEL 10. .. Comentario breve de una sola línea. Markup Validation and Quality ============================= Every contributor must audit the syntax of their files before submitting a Pull Request using the strict linter: .. code-block:: bash rstcheck ruta/al/archivo.rst Acceptance Criteria: * Zero syntax errors in the ``crstlint`` and ``rstcheck`` validators. * Zero inconsistencies in heading underline lengths. * Full compliance with the **zero spaces** around forward slashes rule. * No trailing whitespace at the end of lines.