When developing an application, it can be very useful to have quick access to the details of a method (e.g., an explanation of what it does, its syntax, and a definition of the parameters passed to it). This becomes even more important when using a compiled component. You can’t look at the content of the method, so you can only rely on its documentation to understand how to use it.
The Explorer’s dialog has been enhanced and documentation is now available in 4D v18 R3 for project databases.
Documentation is saved in a file with the same name as the method or form in a documentation folder. The new format for the documentation is Markdown.
Why markdown?
The Markdown language allows you to format text and has a very simple syntax. Thus, the document is easy to read and write, without interrupting its interpretation.
Many tools use Markdown for formatting documentation. For example, GitHub provides a built-in Markdown interpreter.
Documentation in 4D
Documentation is available for:
- Project methods
- Database methods
- Trigger methods
- Project form methods
- Table form methods
- Classes
When you export your binary database as a project, your existing documentation is saved in Markdown-formatted files.
To create or edit the documentation file in a project database, click on the “Create” button or select the “Edit Documentation” menu item in the Explorer.
4D creates the corresponding file and opens it in your default editor. The file includes a template:
<!-- Type your summary here --> ## Description ## Example ```4d Type your example here ```
You can see that the first line uses the HTML comment tags. This information is displayed in the method editor when you hover the cursor over the method. The rest of the file is displayed in the “Documentation” tab of the explorer.
Example
If we use the getWeekday method as an example, here is the result:
In an upcoming blog post, we’ll show you how to make use of comments to write your own documentation for components. Stay tuned!