2017 © Pedro Peláez
 

project phd

PHP DocBook Rendering System

image

php/phd

PHP DocBook Rendering System

  • Monday, July 23, 2018
  • by salathe
  • Repository
  • 12 Watchers
  • 42 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 1 Open issues
  • 1 Versions
  • 19 % Grown

The README.md

PhD - PHP DocBook

About PhD

PhD is PHP's DocBook rendering system which is used to convert the PHP Manual into different output formats., (*1)

If you would like to contribute to PHP's documentation please refer to the contribution guidelines., (*2)

If you would like to know more about how PHP's documentation is built and what the different parts of its pipeline are, please refer to the documentation overview., (*3)

Requirements

  • PHP 8.1+
  • DOM, libXML2, XMLReader and SQLite3.

Running the test suite

Running the test suite uses the same test runner as the php-src repository., (*4)

$ make test

Rendering the PHP Documentation Sources

To render the PHP documentation, you will need to clone the documentation source files, doc-base and PhD., (*5)

To get the PHP documentation sources, clone them from the official GitHub repositories. To clone the English documentation:, (*6)

$ git clone https://github.com/php/doc-en en

List of languages/repositories
, (*7)

To check the documentation and combine it into one file, you need to clone PHP's doc-base repository, (*8)

$ git clone https://github.com/php/doc-base

and run configure.php, (*9)

$ php doc-base/configure.php

which will generate a .manual.xml file in the doc-base directory., (*10)

To render the documentation in xhtml format into the default ./output/ directory:, (*11)

$ php phd/render.php -d doc-base/.manual.xml -P PHP -f xhtml

xhtml files are standalone files that can be opened directly in a browser. To render the documentation in the same php format used on the php.net website:, (*12)

$ php phd/render.php -d doc-base/.manual.xml -P PHP -f php

Please refer to the appropriate section of the contribution guidelines on setting up a local mirror of the PHP documentation., (*13)

PhD's rendering options

The following sections list PhD's the most frequently used options. To see the list of all options run PhD with the -h \ --help option., (*14)

Input

-d \ --docbook <filename> The Docbook file to render, (*15)

-p \ --partial <id[=bool]> Partial rendering: the ID to render, optionally skipping its children chunks (default to true; render children), (*16)

-s \ --skip <id[=bool]> Partial rendering: the ID to skip, optionally skipping its children chunks (default to true; skip children), (*17)

Output

-P \ --package <packagename> The package to use. If a package is specified without a format the input file is rendered in every format of the package. For a list of supported packages, see the list of Supported output formats., (*18)

-f \ --format <formatname> The build format to use. If no package is specified, the appropriate format of the Generic package is used. For a list of supported formats, see the list of Supported output formats, (*19)

-o \ --output <directory> The output directory (default: .), (*20)

Indexing

-I \ --noindex Do not index before rendering but load from cache. (default: false), (*21)

-M \ --memoryindex Do not save indexing into a file, store it in memory. (default: false), (*22)

-r \ --forceindex Force re-indexing. (default: false), (*23)

Information

-h \ --help Lists all available options., (*24)

-l \ --list Lists all supported packages and formats., (*25)

Syntax highlighting

Part of the documentation of programming languages is source code examples. PhD is able to colorize the source code of many types of source code with the help of highlighters., (*26)

To utilize syntax highlighting, your opening <programlisting> tags need a role attribute describing the type of source code. Examples are php, html and python., (*27)

NOTE: PhD currently only highlights the code if it is embedded in a CDATA section., (*28)

<programlisting role="php"><![CDATA[
<?php
echo "Hello world!";
?>
]]></programlisting>

By default, PhD uses the source code highlighter that is built into PHP itself which is only able to highlight PHP code., (*29)

If your documentation contains other types of source code or markup, you can write a custom syntax highlighter., (*30)

Writing a custom syntax highlighter

A syntax highlighter for PhD is nothing more than a simple PHP class that has two methods: factory and highlight., (*31)

factory is static, takes the format name (i.e. pdf, xhtml, troff) as its only parameter and returns the highlighter instance object for the given format. The method is called for each output format the documentation is rendered to., (*32)

highlight takes three parameters: text, role and format. It is called whenever a piece of source code needs to be highlighted and expects the highlighted source code to be returned in the format of the current rendering format., (*33)

Take a look at the provided highlighters, phpdotnet\phd\Highlighter, phpdotnet\phd\Highlighter_GeSHi and phpdotnet\phd\Highlighter_GeSHi11x. They will serve as good examples on how to implement your own highlighter., (*34)

Once you wrote your custom source code highlighting class, it's time to try it out., (*35)

Supported output formats

PhD currently supports the following output formats:, (*36)

PACKAGE Generic IDE PEAR PHP
FORMAT xhtml xml xhtml xhtml
bigxhtml funclist bigxhtml bigxhtml
manpage json php php
php chm chm
phpstub tocfeed tocfeed
sqlite manpage
howto
pdf
bigpdf
kdevelop
epub
enhancedchm

The Versions

23/07 2018

dev-master

9999999-dev http://doc.php.net/phd.php

PHP DocBook Rendering System

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-dom *
  • ext-sqlite3 *
  • ext-xmlreader *