PHP Output

This is new feature in upcoming PasDoc 0.17.0. Not yet available in stable 0.16.0.

PHP output of PasDoc generates a map that can be used to find identifiers in your HTML documentation.

It works closely with PasDoc HTML output generator. If HTML output generator would generate output for identifier Foo in file Aaa.html, with anchor Foo, then the PHP output allows you to map FooAaa.html#Foo.

If you have a website using PHP, and you include there HTML documentation generated by PasDoc, you can use the generated map to:

  • implement server-side searching within your documentation,

  • enumerate all possible Pascal identifiers (e.g. to have auto-complete in the search box),

  • utilities to compose links to API docs. E.g. Castle Game Engine is using it to define simple AsciiDoctor macros like cgeapi:TCastleScene[]. Underneath it uses PHP map to resolve TCastleScene to CastleScene.TCastleScene.html.

A sample output looks like this:

<?php
global $pasdoc;
$pasdoc = array(
  'Foo' => array('html_filename' => 'UnitWithConstants.html#Foo', 'type' => 'constant'),
  'Bar' => array('html_filename' => 'UnitWithConstants.html#Bar', 'type' => 'constant'),
  'TMyClass' => array('html_filename' => 'UnitContainingMyClass.TMyClass.html', 'type' => 'class'),
  'TMyClass.Method' => array('html_filename' => 'UnitContainingMyClass.TMyClass.html#Method', 'type' => 'procedure'),
);

In your PHP application, you could use it, for example to define a searching function:

<?php
require_once 'docs.php';

// Return link to given Pascal identifier, or NULL if not found.
function find_pascal_identifier($name)
{
  global $pasdoc;
  if (array_key_exists($name, $pasdoc)) {
    return $pasdoc[$name]['html_filename'];
  } else {
    return NULL;
  }
}

Or you can write statistics about Pascal identifiers:

<?php
require_once 'docs.php';

global $pasdoc;
echo 'Found ' . count($pasdoc) . ' Pascal identifiers.';