New GD Knowledge Base Pro 6.0 has been expanded with new blocks that will simplify code documentation. These new blocks are highly configurable, and you can practically change everything, including labels for all the included elements.
Suppose you have a WordPress plugin or any other software and must document the functions, classes, shortcodes, or hooks (WordPress-specific actions and filters). This is not an easy thing to do without some tools to make the process simpler and faster. And, with the block editor available for WordPress, it is now possible to have more advanced blocks made for this type of task.
To make the documentation creation in WordPress easier, you should use GD Knowledge Base Pro. It supports multiple content types, including FAQ, works with any theme, includes multiple layouts for all page types, has powerful terms filtering, supports block editor, and includes 10+ blocks, along with other useful features (Table of Contents, Live AJAX search…) and integrations (bbPress and WooCommerce). Check out more about the plugin on its home page.
While in the Block Editor, all the GD Knowledge Base Pro blocks are located under the GD Knowledge Base category. Currently, there are 11 blocks you can use directly (and two extra blocks that will work only as part of other blocks).
This article will focus on the last two blocks: Source Code and Value List.
Source Code allows you to define the function (or method, shortcode action, or filter), including where it is located in the code, list every argument (including argument type, default value, and description), and include which exceptions are thrown and what is returned.
The Value List lists and explains the array or object and the key/value data it stores. And the plugin has a tool that can auto-generate Source Code blocks (or create reference posts) using manual data entry (supporting PHPDoc format) or PHP reflection to get the data.
Source Code Block
Add the Source Code block to the editor, and you will have preconfigured and blank block where you can add your function, method, shortcode, or hook information. The Source Code sidebar inspector has many options to control the block’s content. The most important thing is the Type, where you can choose what the block is about. Practically everything can be edited. You can change heading elements simply by clicking/positioning on the heading you want to edit and change the text. When you change the type, the line where the definition is displayed will change to accommodate the type differences.
The image below shows the block in the editor with information about the function.
If your function doesn’t have arguments, you can hide the attributes line and the whole Arguments section. If the function throws an Exception, you can enable the Throws section. If the function doesn’t return anything, disable the Returns section. It is quite simple to use.
When this block is displayed on the front page, it will look almost the same; the only hidden thing is white boxes for adding data.
Value List Block
This is a simpler block to list Key/Value pairs with descriptions. This is usually used for arrays or objects. You can hide the key or description columns. You can add one or more values and describe them to help your users with explanations of values.
I have started converting Dev4Press Knowledge Base and will expand it soon using these blocks, and for now, you can check out some examples that use these blocks: Shortcode [gdbbx_profile_items] and Function gdbbx_is_topic_locked().
What other types of blocks related to code documentation would you like to see, or how can I improve these new blocks to make them more flexible?