Blog Post

Easier knowledge base code documenting

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.

The Source Code block with a definition for a 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.

Block displayed on the front end.

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.

Values List block in action

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?

Please wait...
GD Knowledge Base Pro plugin for WordPress
The knowledge base plugin you have been waiting for

Complete knowledge base system supporting all themes, with different content types, FAQ, products, live search, feedbacks and ratings, built-in analytics and more.

About the author

Milan Petrovic
Milan Petrovic

CEO and Lead developer of Dev4Press Web Development company, working with WordPress since 2008, first as a freelancer, later founding own development company. Author of more than 250 plugins and more than 20 themes.

Subscribe to Dev4Press Newsletter

Get the latest announcements, release digests, promotions and exclusive discounts, and general Dev4Press-related news straight into your mailbox.

This form collects your email (optionally your name) for the purpose of sending you newsletters. Check out our Privacy Policy for more information on how we store and manage your data. We will not send you any spam. Newsletters are sent 2 to 4 times every month.

Latest From The Blog

setup packages

Introducing Setup Packages

By popular request, Dev4Press now includes setup packages that can be purchased along with the plugin licenses and include plugin setup and training with the Dev4Press Support team via Meet, Zoom, or Skype.
antispam wpforms

Fighting spam in WPForms Lite & Pro

WPForms is a very popular plugin for creating contact forms, and a free version is available in the repository. But both versions have very basic spam protection, and that's why coreSecurity Pro has an Antispam feature for the WPForms plugin.
gravity forms antispam results

Gravity Forms Antispam results

We have used the Gravity Forms plugin on Dev4Press for over ten years now, and having a good antispam solution is essential to keep contact form entries clean and not waste time sorting out what is spam or not.

Leave a Comment

Grammarly - Number 1 Writing App
SiteGround - Managed WordPress Hosting