Perfect Drupal modules for developers to write technical documentation

By xngo on February 19, 2019

Overview

Let's face it. No one wants to write documentations, except maybe the techinical writers? In order to make it less painful as possible and maybe more enjoyable, it would requires some thing that is easy to write and less convoluted. No DocBook, please. Here are the two perfect modules:

  • Markdwn is a super lightweight markup language with plain text formatting. There is basically no tag at all. You can easily still read the markup as text without rendering. 1 caveat though. Writing a table is a pain.
  • GeSHi filter does syntax highlighting of source code.

Install Libraries module

If you are not using or can't use composer, then Libraries module is required for both Markdown and Geshi filter modules.

  1. Install Libraries.
  2. Enable it.
  3. Create libraries folder in the Drupal root folder.

Install Markdown module

  1. Install Markdown.
  2. Enable it.
  3. Download the required php-markdown library from https://github.com/michelf/php-markdown/releases.
  4. Extract it and put it in the libraries folder located in Drupal root folder.
  5. Ensure that the final path becomes /libraries/php-markdown/Michelf/MarkdownExtra.inc.php.

Install GeShi Filter module

  1. Install Geshi filter.
  2. Enable it.
  3. Download the required GeSHi library from https://github.com/GeSHi/geshi-1.0/releases.
  4. Extract it and put it in the libraries folder located in Drupal root folder.
  5. Ensure that the final path becomes libraries/geshi/geshi.php.
  6. Clear your Drupal cache. Otherwise, GeSHi library will not be detected.

Setup your Drupal's Text Format

Go to Configuration->Text formats and editors, either create a new text format or use an existing one. Enable both GeSHi and Markdown filters. Ensure that the order of the Filter processing order is as follow:

  1. GeSHi filter (1st)
  2. Markdown (last)

Recommendation

Geshi filter allows you to put your source code between different type of tags.

  • <code type="java">
  • <blockquote language="java">
  • <java>

I recomend you to use the first way, <code type="java">. I know that it is a little bit longer to write than <java> but it is more portable. Later, if you wish, you can easily switch to another syntax highlighting library.

Reference

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.