DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:doxycode

doxycode Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" yes
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" unknown
  • 2020-07-29 "Hogfather" unknown

plugin Parse code snippets in dokuwiki with cross referencing to doxygen documentation.

Last updated on
2024-02-16
Provides
Syntax, Helper, Admin, Action, Remote
Repository
Source

Description

This plugin implements syntax-highlighted code snippets with cross referencing to external Doxygen documentations. It is designed for users who want to integrate detailed code analysis into their documentation.

Doxycode leverages Doxygen's ability to parse and cross-reference code by exporting the content of the code snippets as source files and executing a Doxygen build in the background. It then parses the XML output of Doxygen as HTML that mimics the style of DokuWiki's default code blocks. Doxygen tag files from existing documentations are used during the build process for the cross-references. Doxycode extracts the detected references from the XML output and creates links inside the code snippets to the corresponding documentation.

This integration offers a seamless blend of DokuWiki's structured documentation format with the analytical depth of Doxygen.

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Examples/Usage

Using doxycode involves the following steps:

  • Creating a tag file configuration (in the admin interface)
  • Downloading tag files
  • Creating a code snippet that uses the tag file

This section only shows how to use doxycode as a user. Refer to the configuration section for an explanation on how to setup the tag file configuration.

Syntax

Basic syntax:

<doxycode tagfiles="tag_name1 tag_name2" [linenumbers] [language="c"] [render_task] [filename.c]>
#include "header.h"

...
</doxycode>
Parameter Description
tagfiles Specifies the tag files to be passed to doxygen during build. The tag names are configured in the admin interface. The tag file selector dialog in the toolbar can be used for quickly finding and inserting the tag file names.
linenumbers If this parameter is provided line numbers are printed.
language=“extension” This string will be used for the file extension of the source file for the Doxygen build. Doxygen will then use this file extension for detecting the language. This parameter is only necessary if the filename was not provided.
render_task
filename.extension If this parameter is provided a download link for the file will be printed in the output. The filename must include the extension and must be the last parameter (before the '>'). The extension will be used for the source file. In this case the language parameter can be omitted.

Toolbar: Tag File Selector

Browsing the available tag files on a DokuWiki instance is made easy with the doxycode toolbar entry. When clicked a dialog opens that loads the list of available tag files via AJAX. The user can select the tag files to be used here.

The tag file selector dialog tries to find an existing doxycode syntax near the cursor position in the editor. If an existing syntax could be found it loads the selected tag files into the results.

When inserting the list of selected tag files it either replaces the tag file list in the existing syntax or inserts a new doxycode syntax at the cursor position in the editor.

Configuration and Settings

This section covers the configuration options for administrators.

Admin Configuration

These configuration parameters can be set through the configuration manager.

Configuration Description
default_update_period This is the duration in seconds after which doxycode will poll externally hosted tagfiles for updates.
runner_max_execution_time Time in seconds the doxygen process is allowed to run.
Each time Doxygen is executed through the task runner the PHP maximum execution time will be set to this value with set_time_limit. Set this parameter to a higher value if the Doxygen build times out.
runner_max_tasks Amount of build tasks the doxycode task runner will execute. This prevents the task runner from executing endlessly if many build tasks are scheduled.

Admin Interface: Configuring the Tag Files

For cross-referencing Doxygen documentations tag files are needed. In this admin interface tag file configuration entries can be created.

Tag files can be loaded onto the server in the following ways:

  • Uploading a file (the filename will be used for creating the entry - be careful existing tag files might be overwritten if the wrong filename is used)
  • Automatically downloading tag files: insert a new entry with the remote URL and the update period set
  • Uploading from CI/CD: insert a new entry without the remote parameters set
Column Description
Del Delete this configuration entry.
Enable Allow usage of this tag file in the wiki.
Force Runner If enabled all code snippets that use this tag file are forced to be build through the task runner. Enable this for large tag files that take long to process.
Local Name This is the tag file name that will be used in the syntax.
File mtime If a tag file exists on the server the last modification time of the file will be shown here.
Documentation URL Root of the external Doxygen documentation (often https://some.domain.com/html/).
Remote URL If a tag file is publicly available you can insert the URL here and doxycode will try to download the tag file.
Update Period How often doxycode will download the remote tag file to check for updates.
Description A short description of what is documented / referenced. This description will be shown in the tag file selector dialog.

TaskRunner: Execute Doxygen Builds in the Background

By default all Doxygen builds are executed in the renderer. When using large tag files the build might take so long that the page times out. Doxycode implements a 'TaskRunner' feature for solving this that can be enabled globally for specific tag files or in the syntax for specific code snippets. Doxycode will then save information about the code snippets and execute the Doxygen build when DokuWiki's taskrunner process is executed.

Doxycode bundles all snippets with the same Doxygen configuration in one 'task'. Each code snippet is called a 'job' in this context. Bundling multiple jobs in one task decreases the build time. The information about the tasks and jobs are saved in SQLite tables with the helper of the sqlite plugin. If the plugin is not installed doxycode falls back to direct build execution during rendering.

:?: Optional requirements: This plugin optionally uses the following additional components that can be installed separately:

When a code snippet is build through the TaskRunner the page will contain a message informing the user about it. If JavaScript is available the page will periodically request the build state via AJAX. After the build job finished the page will dynamically load the snippet via AJAX.

Upload Tag Files from CI/CD Pipelines

The main way for obtaining tag files is through remote configurations where the tag files are available publicly and periodically downloaded by doxycode. For private projects where the source code and the documentation are not public, doxycode offers the possibility of uploading tag files from CI/CD pipelines via a remote API call to the DokuWiki instance.

The upload is implemented in a python script that is available here: https://github.com/lprobsth/doxycode_py_upload

It either uses the old XML RPC API or the newer JSON RPC API. The script will select the API interface based on the credentials provided to the script:

  • XML RPC API for username/password
  • JSON RPC API for API tokens

Refer to https://github.com/lprobsth/doxycode_py_upload/tree/main?tab=readme-ov-file#usage for how to use the python upload script.

In the following sections some basic examples for CI/CD uploads are given.

GitLab Runner

Create the CI/CD variables for the credentials either for the group, user or project. Please note that the variables are not considered secure - they might be leaked into logs or obtained through the console. GitLab works on a credential provider for the GitLab runners. But for now the CI/CD variables have to be used.

Example pipeline:

image: python:3-alpine

pages:
  script:
  - apk update && apk add doxygen graphviz ttf-freefont git
  - pip install dokuwikixmlrpc
  - git clone https://github.com/lprobsth/doxycode_py_upload.git
  - doxygen docs/doxygen.conf
  - ./doxycode_py_upload/upload_tag_file.py docs/canopen_dictionary_lib.xml
  - mv docs/html/ public/
  - mv docs/*.xml public/
  artifacts:
    paths:
    - public
  only:
  - main

Here the tag file 'canopen_dictionary_lib.xml' is uploaded and the doxygen documentation is published to GitLab Pages.

Development

The source code of the plugin is available at GitHub: https://github.com/lprobsth/dokuwiki-plugin-doxycode.

Please report issues and feature requests in the bug tracker at https://github.com/lprobsth/changes/dokuwiki-plugin-doxycode

The following list only serves as a quick overview of the most important issues and ToDo's.

Changelog

Known Bugs and Issues

ToDo/Wish List

  • Implement global setting for executing builds through the task runner.
  • Implement function for cleaning the sqlite tables.
  • Add more CI/CD examples.
  • Add technical background (what are tag files?) to the wiki page.
  • Implement detailed output of log if doxygen build fails (currently it just displays a simple message).
  • Add option for embedding externally hosted code.
  • Add taglist syntax to the usage section in the wiki page.
  • Implement better taglist syntax for listing all available tag files.

FAQ

plugin/doxycode.txt · Last modified: 2024-02-16 17:30 by lprobsth

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki