User's Guide
Reference Manual
Release Notes
PDF
Top

DocBuilder
Reference Manual
Version 0.9.8.11

Expand All
Contract All

Table of Contents

# docb_gen

### MODULE

docb_gen

### MODULE SUMMARY

Generate XML from EDoc comments in Erlang source code.

### DESCRIPTION

docb_gen contains functions for generating XML documentation source code according to the erlref or chapter DTD from EDoc comments in Erlang source code or an overview.edoc file, using EDoc.

### EXPORTS

module(File) -> ok | {error, Reason}
module(File, Options) -> ok | {error, Reason}

Types:

File = string()
Options = [Opt]
Opt = {def,Defs} | {includes,Dirs} | {preprocess,Bool} | {sort_functions,Bool}
Defs = [{atom(),string()}]
Dirs = [string()]
Bool = bool()
Reason = badfile | {badopt,term()} | term()

Generates XML documentation source code according to the erlref DTD from EDoc comments File, using the EDoc application.

File is an Erlang source file, given with or without the .erl extension as Name.erl or Name. The resulting XML file is created in the current working directory and named Name.xml.

Options is a list of options, see below.

Returns ok if successful, and an error tuple otherwise.

users_guide(File) -> ok | {error, Reason}
users_guide(File, Options) -> ok | {error, Reason}

Types:

File -- see module/1,2
Options -- see module/1,2
Reason -- see module/1,2

Like module/1,2 but generates XML source code according to the chapter DTD from an overview.edoc or similar file.

The resulting file is named chapter.xml.

### Options

{def, [{Name,Text}]}
  Specifies EDoc macro definitions. See edoc:get_doc/2.
{includes, [Dir]}
  Specifies directories where EDoc should search for include files. See edoc:read_source/2.
{preprocess, true|false}
  Specifies if EDoc should read the source file via the Erlang preprocessor. Default is false. See edoc:read_source/2.
{sort_functions, true|false}
  Specifies if the functions in the resulting XML file should be sorted alphabetically. Default is true.

### Limitations

The mapping from the EDoc XHTML output to valid Erlang/OTP XML is not complete. An attempt has been made to cover the most commonly used XHTML constructs, but there will still be cases where XML generation fails or where the resulting XML is inadequate. This is especially true for users_guide/1,2.

Known limitations for some XHTML tags:

<a>

  All attributes except the first href or name attribute are ignored.

  A href attribute means the <a> tag will be transformed to a <seealso> or <url> tag and an attempt is made to resolve the reference if necessary.

  A name attribute means the <a> tag will be transformed to a <marker> tag.

<b>, <em>, <pre>
  Cannot contain other tags in Erlang/OTP XML, content is converted to plain text.
<center>
  No corresponding Erlang/OTP XML tag, converted to plain text.
<font>
  No corresponding Erlang/OTP XML tag, converted to plain text.
<h1>, <h2>, ...
  There is no tag corresponding to a header in Erlang/OTP XML, so these are converted to plain text instead, with the exception of <h3> and <h4> tags within overview.edoc, see part about "chapter DTD" below.
<sup>
  There is no tag corresponding to superscript in Erlang/OTP XML, so this is converted to plain text within brackets "(..)".
References
  The markers automatically inserted by EDoc at each heading and function will override the markers automatically inserted by DocBuilder, with the unfortunate result that the links in the left-hand frame of the User's Guide will not work, and also that cross referencing a function in a module the usual Erlang/OTP way "<seealso marker="edoc:edoc#run/3...>" does not work. (But "<seealso marker="edoc:edoc#run-3...>" does.)

erlref DTD

Tables
  Tables are not allowed. The contents of a table is converted to text instead, each row corresponding to one line of text.

chapter DTD

Sections
  Only two levels of sections. <h3> (equivalent to EDoc headings "== Heading ==") is interpreted as start of top-level section, or if there is no <h3> tag, the entire document is made into one top-level section. <h4> (equivalent to EDoc sub-headings ("=== Sub-heading ===") is interpreted as start of second-level section.
Tables
  Tables without borders are converted to text in the same manner as for the erlref DTD.