1.1.0 • Published 5 months ago

doxsite v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

doxsite

Utility for creating highly customised documentation websites with XML generated by Doxygen.

This package has been created with C# projects in mind. Doxygen is capable of producing data for a number of programming languages, however this package has not been tested with data from projects other than C#.

Requirements

This package uses XML output from Doxygen to generate a documentation website for annotated C# code. See the Getting started page on the Doxygen website for details on installing and running Doxygen.

It is worth noting that only the XML output is required to use the doxsite package, so all other forms of output can be ignored.

Installation

It is recommended to install doxsite globally, so as to get access to the command line interface (CLI). The CLI will make creating new projects easier as well as give you the option to forego additional node scripts for building your documentation site.

To install globally:

$ npm install -g doxsite

If you would like to use the package in your node scripts after installing globally, you will need to link doxsite to your local project:

$ npm link doxsite

Getting started

1. Create a new project

The easiest way to get started is to use the command line interface to set up a default project. cd into the folder you wish to create your documentation in and run:

$ doxsite -n

This command will create the following folders/files:

Folder/FileDescription
developRoot folder for the documentation website's development.
develop/APIOutput folder for documentation pages.
develop/scripts/nav.jsScript responsible for nav tree functionality on each page of the site. Handles expand/collapse of namespaces and resizing of the nav tree column.
develop/styles/documentation.cssStylesheet for the website.
doxygenFolder containing Doxygen related files.
doxygen/DoxyfileThe config file to use when running Doxygen. You will need to modify the INPUT option to point to your project. All other options will be configured to work with this folder/file structure.
doxygen/XMLOutput directory for XML produced by Doxygen. Doxyfile points to this folder.
templatesFolder containing html templates to build the documentation pages with.
templates/tempaltes.jsonTemplate config file. Defines which html files to use for each section/element of a documentation page.

2. Modify Doxygen input

Next modify the INPUT option in the Doxyfile to point to the folders you want to generate documentation for. You can enter multiple paths separated by spaces, eg:

INPUT = "../Project/Company/Scripts" "../Project/Project/Scripts" "../Project/Some Other/Scripts"

By default the Doxyfile will have the RECURSIVE option set to YES so all sub folders will be traversed when Doxygen runs.

3. Run Doxygen

If Doxygen is installed on the command line, run the following command:

$ doxygen doxygen/Doxyfile

The doxygen/XML folder will now contain the data needed by doxsite.

4. Run doxsite

To run doxsite from the command line:

$ doxsite -x doxygen/XML -t templates/templates.json -o develop -a API

Or from a Node script:

import { Doxsite } from 'doxsite';

Doxsite.buildDocs({
	xmlPath: 'doxygen/XML',
	templates: 'templates/templates.json',
	outputPath: 'develop',
	apiSubPath: 'API',
	searchdataSubPath: 'scripts'
});

Site customisation

doxsite generates a website by parsing the XML output of Doxygen and injecting that data into HTML templates. The templates use predefined variables (in the format $variablename) where content generated by doxsite should be inserted. This gives you near total control of the layout, styling and scripts used on each page.

templates.json

The easiest way to supply template data is using a templates.json file that defines which files/content to use for each template. The default project created using doxsite -n provides a file that can be used as a reference under templates/templates.json.

A templates .json file should contain two root level properties:

PropertyTypeDescription
filePathStringPath where templates files are located, relative to this json file.
filesObjectObject where each property is the name of a template, and its value is the name of a file whose content to use.

HTML templates

The following table lists all valid template properties that can be provided in templates.json.

TemplateDescription
pageThe default template that all documentation pages are constructed from (the layout template for a page).
memberDeclarationMarkup for type/member declarations.
memberInheritsMarkup for listed type inheritance.
memberImplementsMarkup for interfaces implemented by a type.
memberNamespaceMarkup for the listed item's namespace.
memberAssemblyMarkup for the listed item's assembly.
navNamespaceMarkup for a namespace that appears in the nav tree on a page.
navMemberMarkup for an item (class/struct/enum etc.) that is listed in the nav tree under a namespace.
navMemberThisMarkup for an item (class/struct/enum etc.) that is listed in the nav menu whose page it is.
navMemberMemberMarkup for an item (class/struct/enum etc.) that is listed in the nav menu whose member's page it is.
descriptionSectionMarkup for the description section of a page.
typeParameterSectionMarkup for the section of a page that documents an item's type/template parameters.
typeParameterMarkup for a documented type/template parameter.
fieldSectionMarkup for the section of a page that documents an item's fields.
fieldMarkup for a documented field.
propertySectionMarkup for the section of a page that documents an item's properties.
propertyMarkup for a documented property.
methodSectionMarkup for the section of a page that documents an item's methods.
methodMarkup for a documented method.
eventSectionMarkup for the section of a page that documents an item's events.
eventMarkup for a documented event.
instanceFieldSectionMarkup for the section of a page that documents an item's instance/non-static fields. If not supplied, the content of fieldSection is used instead.
instanceFieldMarkup for a documented instance/non-static field.
instancePropertySectionMarkup for the section of a page that documents an item's instance/non-static properties. If not supplied, the content of propertySection is used instead.
instancePropertyMarkup for a documented instance/non-static property.
instanceMethodSectionMarkup for the section of a page that documents an item's instance/non-static methods. If not supplied, the content of methodSection is used instead.
instanceMethodMarkup for a documented instance/non-static method.
instanceEventSectionMarkup for the section of a page that documents an item's instance/non-static events. If not supplied, the content of eventSection is used instead.
instanceEventMarkup for a documented instance/non-static event.
publicFieldSectionMarkup for the section of a page that documents an item's public fields. If not supplied, the content of fieldSection is used instead.
publicFieldMarkup for a documented public field.
publicPropertySectionMarkup for the section of a page that documents an item's public properties. If not supplied, the content of propertySection is used instead.
publicPropertyMarkup for a documented public property.
publicMethodSectionMarkup for the section of a page that documents an item's public methods. If not supplied, the content of methodSection is used instead.
publicMethodMarkup for a documented public method.
publicEventSectionMarkup for the section of a page that documents an item's public events. If not supplied, the content of eventSection is used instead.
publicEventMarkup for a documented public event.
protectedFieldSectionMarkup for the section of a page that documents an item's protected fields. If not supplied, the content of fieldSection is used instead.
protectedFieldMarkup for a documented protected field.
protectedPropertySectionMarkup for the section of a page that documents an item's protected properties. If not supplied, the content of propertySection is used instead.
protectedPropertyMarkup for a documented protected property.
protectedMethodSectionMarkup for the section of a page that documents an item's protected methods. If not supplied, the content of methodSection is used instead.
protectedMethodMarkup for a documented protected method.
protectedEventSectionMarkup for the section of a page that documents an item's protected events. If not supplied, the content of eventSection is used instead.
protectedEventMarkup for a documented protected method.
staticFieldSectionMarkup for the section of a page that documents an item's static fields. If not supplied, the content of fieldSection is used instead.
staticFieldMarkup for a documented static field.
staticPropertySectionMarkup for the section of a page that documents an item's static properties. If not supplied, the content of propertySection is used instead.
staticPropertyMarkup for a documented static property.
staticMethodSectionMarkup for the section of a page that documents an item's static methods. If not supplied, the content of methodSection is used instead.
staticMethodMarkup for a documented static method.
staticEventSectionMarkup for the section of a page that documents an item's static events. If not supplied, the content of eventSection is used instead.
staticEventMarkup for a documented static event.
publicStaticFieldSectionMarkup for the section of a page that documents an item's public static fields. If not supplied, the content of staticFieldSection, publicFieldSection or fieldSection will be used (in that order, first that contains content).
publicStaticFieldMarkup for a documented public static field.
publicStaticPropertySectionMarkup for the section of a page that documents an item's public static properties. If not supplied, the content of staticPropertySection, publicPropertySection or propertySection will be used (in that order, first that contains content).
publicStaticPropertyMarkup for a documented public static property.
publicStaticMethodSectionMarkup for the section of a page that documents an item's public static methods. If not supplied, the content of staticMethodSection, publicMethodSection or methodSection will be used (in that order, first that contains content).
publicStaticMethodMarkup for a documented public static method.
publicStaticEventSectionMarkup for the section of a page that documents an item's public static events. If not supplied, the content of staticEventSection, publicEventSection or eventSection will be used (in that order, first that contains content).
publicStaticEventMarkup for a documented public static event.
protectedStaticFieldSectionMarkup for the section of a page that documents an item's protected static fields. If not supplied, the content of staticFieldSection, protectedFieldSection or fieldSection will be used (in that order, first that contains content).
protectedStaticFieldMarkup for a documented protected static field.
protectedStaticPropertySectionMarkup for the section of a page that documents an item's protected static properties. If not supplied, the content of staticPropertySection, protectedPropertySection or propertySection will be used (in that order, first that contains content).
protectedStaticPropertyMarkup for a documented protected static property.
protectedStaticMethodSectionMarkup for the section of a page that documents an item's protected static methods. If not supplied, the content of staticMethodSection, protectedMethodSection or methodSection will be used (in that order, first that contains content).
protectedStaticMethodMarkup for a documented protected static method.
protectedStaticEventSectionMarkup for the section of a page that documents an item's protected static events. If not supplied, the content of staticEventSection, protectedEventSection or eventSection will be used (in that order, first that contains content).
protectedStaticEventMarkup for a documented protected static event.
typeSectionMarkup for the section of a field or property page's that documents its type.
parameterSectionMarkup for the section of a method's page that documents its parameters.
parameterMarkup for a documented method parameter.
returnSectionMarkup for the section of a method's page that documents its return value.
overloadSectionMarkup for the section of a method's page that documents its overloards.
valueSectionMarkup for the section of an enum's page that documents its values.
valueMarkup for a documented enum value.

Template variables

The following variables are used in the HTML templates and replaced when constructing the website. Variables are removed from the output pages in cases where they aren't needed (e.g. A page documenting a field won't contain a section for method parameters), or if no content is supplied.

VariableDescription
$rootpathPath to the website's root. e.g. /docs/api. Used in the page template.
$navsectionSection on each page containing the site's navigation menu. Used in the page template.
$navnamespaceA namespace that appears in the navigation menu on each page. Used in the page template.
$navmembersUsed in the navSection template where members of a namespace should be inserted.
$navmembernameUsed in the navMember template where the name of a member of a namespace should be inserted.
$navmemberurlUsed in the navMember template where the link to the page for a member of a namespace should be inserted.
$membernameUsed in the page template where the name of the item being documented should be inserted.
$memberfullnameUsed in the page template where the full name of the item (in the format "OwningType.ItemName") being documented should be inserted.
$memberqualifiednameUsed in the page template where the qualified name of the (in the format "Namespace.OwningType.ItemName") item being documented should be inserted.
$membernametextUsed in the page template where the name of the item being documented should be inserted (in plain text).
$membertypetextUsed in the page template where the definition type (class, struct, method, property etc.) of the item being documented should be inserted (in lowercase).
$membertypetitletextUsed in the page template where the definition type (class, struct, method, property etc.) of the item being documented should be inserted in Title Case.
$memberdeclarationUsed in the page template where the documented item's declaration should be inserted.
$memberinheritsUsed in the page template where a documented item's parent type should be inserted.
$memberimplementsUsed in the page template where interfaces a documented item implements should be inserted.
$membernamespaceUsed in the page template where a documented item's containing namespace should be inserted.
$memberassemblyUsed in the page template where a documented item's containing assembly should be inserted. Limited as Doxygen doesn't export assembly data. The namespace is assumed as assembly.
$memberownerUsed in the page template where a documented item's owning type's name should be inserted.
$descriptionsectionUsed in the page template where a documented item's description should be inserted.
$typeparametersectionUsed in the page template where a documented item's type/template parameters should be inserted.
$typeparametersUsed in the typeParameterSection template where the individual type/template parameters should be inserted.
$typeparameternameUsed in the typeParameter template where the type/template parameter name/identifier should be inserted.
$typeparameterdescriptionUsed in the typeParameter template where the type/template parameter description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$accesstextUsed in member section templates (fieldSection, methodSection, etc.) where a member's access modifier should be inserted (in lowercase).
$accesstitletextUsed in member section templates (fieldSection, methodSection, etc.) where a member's access modifier should be inserted in Title Case.
$fieldsectionUsed in the page template where the section documenting an item's fields should be inserted.
$fieldsUsed in field section templates (fieldSection, instanceFieldSection, publicStaticFieldSection etc.) where the individual fields should be inserted. Fields are inserted as markup defined in the field template.
$fieldtypeUsed in the field template where the field's type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$fieldnameUsed in the field template where the field's name should be inserted. Names are inserted as links (<a> elements) to the field's documentation page.
$fielddescriptionUsed in the field template where the field's description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$propertysectionUsed in the page template where the section documenting an item's properties should be inserted.
$propertiesUsed in property section templates (propertySection, instancePropertySection, publicStaticPropertySection, etc.) where the individual properties should be inserted. Properties are inserted as markup defined in the property template.
$propertytypeUsed in the property template where the property's type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$propertynameUsed in the property template where the property's name should be inserted. Names are inserted as links (<a> elements) to the property's documentation page.
$propertyaccessorsUsed in the property template where the property's accessors (get/set) should be inserted. Accessors are inserted as plain text.
$propertydescriptionUsed in the property template where the property's description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$methodsectionUsed in the page template where the section documenting an item's methods should be inserted.
$methodsUsed in method section templates (methodSection, instanceMethodSection, publicStaticMethodSection, etc.) where the individual methods should be inserted. Methods are inserted as markup defined in the method template.
$methodtypeUsed in the method template where the method's return type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$methodnameUsed in the method template where the method's name should be inserted. Names are inserted as links (<a> elements) to the method's documentation page.
$methodparametersUsed in the method template where the method's parameters should be inserted. Parameters are inserted as markup containing links (<a> elements) to types documented in the project.
$methoddescriptionUsed in the method template where the method's description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$eventsectionUsed in the page template where the section documenting an item's events should be inserted.
$eventsUsed in event section templates (eventSection, instanceEventSection, publicStaticEventSection etc.) where the individual events should be inserted. Events are inserted as markup defined in the event template.
$eventtypeUsed in the event template where the event's type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$eventnameUsed in the event template where the event's name should be inserted. Names are inserted as links (<a> elements) to the event's documentation page.
$eventdescriptionUsed in the event template where the event's description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$instancefieldsectionUsed in the page template where the section documenting an item's instance/non-static fields should be inserted.
$instancepropertysectionUsed in the page template where the section documenting an item's instance/non-static properties should be inserted.
$instancemethodsectionUsed in the page template where the section documenting an item's instance/non-static methods should be inserted.
$instanceeventsectionUsed in the page template where the section documenting an item's instance/non-static events should be inserted.
$publicfieldsectionUsed in the page template where the section documenting an item's public fields should be inserted.
$publicpropertysectionUsed in the page template where the section documenting an item's public properties should be inserted.
$publicmethodsectionUsed in the page template where the section documenting an item's public methods should be inserted.
$publiceventsectionUsed in the page template where the section documenting an item's public events should be inserted.
$protectedfieldsectionUsed in the page template where the section documenting an item's protected fields should be inserted.
$protectedpropertysectionUsed in the page template where the section documenting an item's protected properties should be inserted.
$protectedmethodsectionUsed in the page template where the section documenting an item's protected methods should be inserted.
$protectedeventsectionUsed in the page template where the section documenting an item's protected events should be inserted.
$staticfieldsectionUsed in the page template where the section documenting an item's static fields should be inserted.
$staticpropertysectionUsed in the page template where the section documenting an item's static properties should be inserted.
$staticmethodsectionUsed in the page template where the section documenting an item's static methods should be inserted.
$staticeventsectionUsed in the page template where the section documenting an item's static events should be inserted.
$publicstaticfieldsectionUsed in the page template where the section documenting an item's public static fields should be inserted.
$publicstaticpropertysectionUsed in the page template where the section documenting an item's public static properties should be inserted.
$publicstaticmethodsectionUsed in the page template where the section documenting an item's public static methods should be inserted.
$publicstaticeventsectionUsed in the page template where the section documenting an item's public static events should be inserted.
$protectedstaticfieldsectionUsed in the page template where the section documenting an item's protected static fields should be inserted.
$protectedstaticpropertysectionUsed in the page template where the section documenting an item's protected static properties should be inserted.
$protectedstaticmethodsectionUsed in the page template where the section documenting an item's protected static methods should be inserted.
$protectedstaticeventsectionUsed in the page template where the section documenting an item's protected static events should be inserted.
$typesectionUsed in the page template where the section documenting a field or property's type should be inserted.
$typeUsed in the typeSection template where the field or property's type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$parametersectionUsed in the page template where the section documenting a method's parameters should be inserted.
$parametersUsed in the parameterSection template where the individual parameters should be inserted. Parameters are inserted as markup defined in the parameter template.
$parametertypeUsed in the parameter template where the parameter's type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$parameternameUsed in the parameter template where the parameter's name should be inserted. Parameter names are inserted as plain text.
$parameterdescriptionUsed in the parameter template where the parameter's description should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$returnsectionUsed in the page template where the section documenting a method's return value should be inserted.
$returntypeUsed in the returnSection where the method's return type should be inserted. Types are inserted as links (<a> elements) where the type is documented in the project, otherwise it is plain text.
$returndescriptionUsed in the returnSection where the description of the method's return value should be inserted. Descriptions are inserted as paragraphs (<p> elements).
$overloadsectionUsed in the page template where the section documenting a method's overloads should be inserted.
$valuesectionUsed in the page template where the section documenting an enum's values should be inserted.
$valuesUsed in the valueSection template where the enum's individual values should be inserted. Enum values are inserted as markup defined in the value template.
$valuenameUsed in the value template where the enum value's name should be inserted. Names are inserted as plain text.
$valuedescriptionUsed in the value template where the description of the enum's value should be inserted. Descriptions are inserted as paragraphs (<p> elements).

Manual

CLI

$ doxsite [options...]
OptionDescription
-h,--helpDisplay manual/usage information.
-n,--new-project <path>Create a new project at <path>. Creates a 'doxygen' folder containing a Doxyfile and XML folder for Doxygen output, and a 'develop' folder for the site with a default stylesheet. If <path> is omitted, project will be created in current working directory.
-d <doxyfile>Runs Doxygen before building documentation site. If <doxyfile> is omitted, Doxygen will attempt to run with a file named Doxyfile in the current working directory.
-x <xmlpath>Path to XML generated by Doxygen. Output location is defined by the OUTPUT_DIRECTORY and XML options in the Doxyfile. 'XML' used if option is omitted.
-i <indexxml>Filename for of the index xml file generated by Doxygen. Located in the xmlpath folder. 'index.xml' used if option is omitted.
-t <templatesjson>Templates used to generate documentation files. Path to a JSON file. Built-in templates used if omitted.
-o <outputpath>Path the documentation files are written to. If omitted, files will be created under a folder named 'API' in the current working directory.
-e <outputfileextension>File extension documentation pages use, typically html, but could also be php. 'html' used if option is omitted.
-r <urlrootpath>URL path to the documentation site root on the server/hosting environment. '/' used if option is omitted.
-a <apisubpath>Relative path from urlrootpath to the documentation files. 'API' used if option is omitted.

JavaScript

Doxsite.createProject(projectPath)

import { Doxsite } from 'doxsite';

Doxsite.createProject('./Documentation');

Create a new project at a specified path. Creates a 'doxygen' folder containing a Doxyfile and XML folder for Doxygen output, a 'develop' folder for the site with a default stylesheet and JavaScript, as well as a 'templates' folder, containing default html templates for building a documentation site.

Parameters

NameTypeDescription
projectPathStringPath to create the project at. If no path is provided the project will be created in the current working directory.

Doxsite.buildDocs(config)

import { Doxsite } from 'doxsite';

Doxsite.buildDocs({
	xmlPath: 'doxygen/XML',
	templates: 'templates/templates.json',
	outputPath: 'develop',
	apiSubPath: 'API',
	searchdataSubPath: 'scripts'
});

Build documentation files using previously generated xml from Doxygen. This method can be re-run on its own after modifiying template files to reduce build time.

Parameters

NameTypeDescription
configObjectA BuildConfig object defining the options to use for generation of the site. If omitted, the defaults defined by BuildConfig will be used.

Doxsite.runDoxygen(doxyfile)

import { Doxsite } from 'doxsite';

Doxsite.runDoxygen('doxygen/Doxyfile');

Run Doxygen on the command line.

Parameters

NameTypeDescription
doxyfileStringPath to the Doxyfile. If no file is provided, Doxygen will attempt to run with a file named Doxyfile in the current working directory.

Doxsite.runBuild(doxyfile, buildConfig)

import { Doxsite } from 'doxsite';

Doxsite.runBuild('doxygen/Doxyfile', {
	xmlPath: 'doxygen/XML',
	templates: 'templates/templates.json',
	outputPath: 'develop',
	apiSubPath: 'API',
	searchdataSubPath: 'scripts'
});

Run Doxygen from the command line and build the documentation site. This method calls Doxsite.runDoxygen and Doxsite.buildDocs in order.

Parameters

NameTypeDescription
doxyfileStringPath to the Doxyfile. If no file is provided, Doxygen will attempt to run with a file named Doxyfile in the current working directory.
buildConfigObjectA BuildConfig object defining the options to use for generation of the site. If omitted, the defaults defined by BuildConfig will be used.

BuildConfig object

Defines options to use for Doxsite.buildDocs.

OptionTypeDescription
xmlPathStringPath to XML generated by Doxygen. Output location is defined by the OUTPUT_DIRECTORY and XML options in the Doxyfile. 'XML' used if omitted.
xmlIndexFileStringFilename for of the index xml file generated by Doxygen. Located in the xmlPath folder. 'index.xml' used if omitted.
templatesString|ObjectTemplates used to generate documentation files. Either a string path to a JSON file or JSON data containing filePath and files properties. Default templates used if omitted. See Site customisation for more details.
outputPathStringPath to the local root of the documentation site where pages will be created.
outputFileExtensionStringFile extension documentation files use, typically html, but could also be php. 'html' used if omitted.
urlRootPathStringURL path to the documentation site root on the server/hosting environment. '/' used if omitted.
apiSubPathStringPath relative from outputPath/urlRootPath where documentation pages will be created/located.
searchdataSubPathStringPath relative from outputPath/urlRootPath where the search data file (searchdata.js) will be created/located.

Support

doxsite is an open-source project that only gets attention around paid work. If you like the tool, consider donating to my PayPal.