PHP Documentation Base

repository·master·Indexed 18 days ago

https://github.com/php/doc-base

Base source files and tools for converting PHP documentation from DocBook 5.2.1 XML into formats like HTML and RTF. Includes the PhD build tool, guidelines for authors and translators, and a suite of QA scripts (such as qaxml-tags.php and qaxml-attributes.php) to ensure structural consistency and XML validity in the PHP Manual.

Tokens
10.3K
Snippets
35
Records
68
Agent score
63%

What's inside php-doc-base

  1. Introduction to PHP Manual Contribution

    master
    The PHP Manual is built from source files using a tool called PhD. The documentation is written using the DocBook 5.2.1 XML schema. Contributions are made by volunteers who write original English content (authors) and translate it into other languages (translators).
  2. Understand the PHP documentation build system

    master

    The PHP documentation is a multi-stage pipeline that converts XML source files into the PHP pages seen on php.net/manual. The process involves four distinct components:

    1. doc- repositories*: Contain the raw XML documentation content (wording and structure) for various languages.
    2. doc-base: A validation and pre-processing tool that combines XML files, handles XInclude/XPointer links, and validates against DTDs.
    3. PhD (PHP DocBook): A rendering engine that converts the processed XML into .php files. It also generates search indices (JSON), CSS, images, and Table of Contents (TOC) files.
    4. web-php: The web server component that serves the generated .php files. It provides the logic for page headers (navigation, search, breadcrumbs) and footers (copyright, contribution notes).
  3. How the PHP manual is built for the website

    master
    The PHP manual and its translations are automatically rebuilt and published to PHP.net via an automated process managed by the PHP Systems team. This process occurs every few hours. If you notice issues with the manual content or translations on the website, you should contact the PHP Systems team at systems@php.net.
  4. Use example output entities

    master

    When providing code examples, choose the correct entity based on whether the output is deterministic:

    • &example.outputs;: Use this when the output is guaranteed to be identical under all conditions.
    • &example.outputs.similar;: Use this when the output might vary between different executions or different machine environments.
  5. Glossary of PHP Manual terminology

    master

    When contributing to the PHP manual, the following terms are used:

    • author: A person who contributes to the original English manual.
    • translator: A person who translates the English manual into another language.
    • {LANG}: A placeholder for your two-letter country code (e.g., doc-en@lists.php.net).

    Note on Brazilian Portuguese: For the Git repository, use pt_br, but for the mailing list suffix, use pt-br.

  6. Understand the PHP Manual file structure

    master

    The PHP Manual sources are organized by topic and extension. For extension documentation, files are located in reference/extension_name/.

    Extension File Patterns

    General Extension Files:

    • book.xml: The main container for the extension; includes other files (like examples.xml) and contains the preface.
    • setup.xml: Contains setup, installation, and configuration documentation.
    • configure.xml: If present, this is automatically included into setup.xml.
    • constants.xml: Lists constants declared by the extension.
    • examples.xml: Contains various usage examples.
    • versions.xml: Contains version information.
    • [topic].xml: Custom topic files (e.g., foo.xml) must be explicitly included via book.xml.

    Procedural Extensions (e.g., calendar):

    • reference.xml: Container for the extension's functions.
    • functions/: A directory containing one XML file per declared function.

    Object-Oriented (OO) Extensions (e.g., imagick):

    • classname.xml: Container for the methods of a class, including basic class information.
    • classname/: A directory containing one XML file per method declared by the class. Note that classname refers to the lowercased name of the class.

    Language-Specific Files

    • language-defs.ent: Contains local XML entities used by the language (e.g., main part titles).
    • language-snippets.ent: Contains longer, frequently used translated XML snippets (e.g., warnings, notes).
    • translation.xml: Stores central translation metadata (intro text, translator list). This file is unique to translation trees and is not in the English source.
  7. What web-php does and its role in serving documentation

    master

    The web-php repository is the runtime environment for php.net. It serves the .php files generated by PhD and provides the functional logic for the site's UI components:

    • Global UI: Generates the top navigation, search bar, copyright, and privacy policy footers.
    • Documentation UI: Generates page-specific headers (breadcrumbs, language dropdown) and footers (contribution call-outs, user notes).
    • Asset Integration: Uses the CSS, images, TOC, and search index/description files generated by PhD to render the documentation pages and power the site's search functionality.
  8. What PhD (PHP DocBook) does and its output

    master

    PhD is the rendering engine that transforms the combined XML, version files, and modification history files (produced by doc-base) into the final .php documentation pages.

    Key responsibilities include:

    • PHP Page Generation: Produces .php files containing metadata (title, breadcrumbs, source path, last modified date, contributor list) and calls to web-php functions for headers and footers.
    • Search Assets: Writes search-index and search-description JSON files.
    • Static Assets: Copies (or downloads) CSS files and images into the output directory.
    • Navigation: Generates and saves Table of Contents (TOC) files used for the right-side navbar on documentation pages.
  9. Manage `xml:id` patterns to avoid build failures

    master

    The PHP Manual uses two distinct patterns for xml:id attributes. Using the wrong pattern or duplicating IDs can cause build issues.

    1. Structural IDs: Used for linking and chunking on DocBook elements (like <chapter> or <section>).

      • Pattern: folder.id (single dot separator).
      • Behavior: The configure.php script will generate warnings if it finds and removes duplicate Structural IDs.
    2. XInclude IDs: Used as targets for XIncludes.

      • Pattern: folder.id..local (double dot separator).
      • Behavior: The configure.php script will remove duplicate XInclude IDs without generating warnings.

    Summary Table:

    ID TypePatternPurpose
    Structuralfolder.idLinking/Chunking
    XIncludefolder.id..localXInclude targets
  10. How the EN-Revision system works

    master

    To ensure translations stay synchronized with the English source, every translated file must include an EN-Revision comment in its header. This comment contains the Git commit hash of the specific English file version that the translation is based on.

    If the commit hash in your translation's EN-Revision matches the current commit hash of the English file, your translation is up-to-date. If they differ, the English source has changed, and your translation needs to be updated to reflect those changes.

    <!-- EN-Revision: [commit_hash] Maintainer: [username] Status: ready -->
  11. What doc-base does and how it processes XML

    master

    The doc-base tool is responsible for validating and combining documentation XML files. It uses a configure.php script to perform the following operations:

    • Pulls version information from repository files.
    • Iterates through the language repository starting from a skeleton/main table of contents (index.php) to include all elements with appropriate IDs.
    • Pulls the modification history file.
    • Generates file entities from the source language directory and writes them back to the same directory.
    • Loads the combined XML into memory.
    • Executes all XInclude and XPointer links.
    • Substitutes entities.
    • Validates the final document against its DTD.