Package: gdscript-docs-maker
GDScript Docs MakerDocs Maker is a set of tools to convert documentation you write inside your code to an online or offline code reference in the markdown format.If you make plugins or a framework for Godot, GDScript Docs Maker will help you save a lot of time documenting your code.It creates documents following Godot's built-in class reference. You can see an example with ourGodot Steering Toolkit documentationTable of ContentsInstallingGetting StartedWriting your code referenceGenerating the markdown filesHugo outputThe manual wayConverting JSONNote: This program requires Godot 3.2+ and Python 3.7+ to work.InstallingYou can install the GDScript Docs Maker python package with pip:# On Linux and MacOS:python3-mpipinstallgdscript_docs_maker# On Windows, if you installed Python 3.7+, you can use:python-mpipinstallgdscript_docs_makerAlthough to use the shell script that simplifies creating the reference,generate_reference, you need to clone this repository. More on that below.Getting StartedIn this section, you will learn to use the program to generate a code reference quickly.This involves two steps. You need to:Write docstrings inside your GDScript code.Use one of the shell programs that ships with this add-on.Writing your code referenceDocstring or doc-comments in GDScript don't have any special markup.You can document classes, properties, and functions with comment blocks placed on the line before their definition:# A linear and angular amount of acceleration.class_nameGSTTargetAcceleration# Linear accelerationvarlinear:=Vector3.ZERO# Angular accelerationvarangular:=0.0# Resets the accelerations to zerofuncreset()->void:linear=Vector3.ZEROangular=0.0If you need long docstrings, you can use multiple commented lines:# A specialized steering agent that updates itself every frame so the user does
# not have to using a KinematicBody2D
# category: Specialized agents
extends GSAISpecializedAgent
class_name GSAIKinematicBody2DAgentGenerating the markdown filesWe wrote two shell scripts to automate the steps in generating a code reference:./generate_referencefor Linux or MacOS, and./generate_reference.batfor Windows.Use either of them to quickly generate your code reference:GenerateacodereferencefromGDScript
Usage:
generate_reference$project_directory[options]Requiredarguments:$project_directory--pathtoyourGodotprojectdirectory.
Thisdirectoryoroneofitssubdirectoriesshouldcontaina
project.godotfile.

Flags:

-h/--help--Displaythishelpmessage.
-o/--output-directory--directorypathtooutputthedocumentationinto.
-f/--format--Either`markdown`or`hugo`.If`hugo`,theoutputdocumentincludesaTOMLfront-matteratthetop.Default:`markdown`.
-a/--author--If--formatis`hugo`,controlstheauthorpropertyintheTOMLfront-matter.To use them:You need to clone this repository or download the source code from astable release.You needgodotto be available on thesystem PATH variable.Hugo outputYou can output markdown files forhugo, the static website engine.To do so, call GDScript docs maker with the--format hugooption. You can use two extra flags with this:--dateYYYY-MM-DD,thedateinisoformat,ifyouwantthedocumentstohaveadateotherthantoday.Default:datetime.date.today()--authorauthor_id,theidoftheauthoronyourhugowebsite,toassignantheauthorforthedocuments.Default:""Here's how I generate the Godot Steering Toolkit's documentation. This command outputs the class reference straight into the website:python3-mgdscript_docs_maker$HOME/Repositories/godot-steering-toolkit/project/reference.json--formathugo--authorrazoric--path$HOME/Repositories/website/content/docs/godot-steering-toolkit/reference/classes/The manual wayIf you want to generate the JSON and convert it manually, there are three steps involved:Copying the GDScript files./godot-scripts/Collector.gdand./godot-scripts/ReferenceCollectorCLI.gdor./godot-scripts/ReferenceCollectorCLI.gdto your Godot 3.2 project.Running the GDScript code with Godot, either from the editor (ReferenceCollector.gd) or by calling Godot from the command line (ReferenceCollectorCLI.gd).Runninggdscript_docs_makeron the reference.json file that Godot generated in the previous step.Note: to parse and collect data from GDScript code, we rely on the GDScript language server that's new in Godot 3.2.Converting JSONCall thegdscript-docs-makerpackage directly using thepython -moption:Usage: gdscript_docs_maker [-h] [-p PATH] [-v] [--dry-run] files [files ...]

Merges or converts json data dumped by Godot's GDScript language server to
create a code reference.

positional arguments:
  files                 A list of paths to JSON files.

optional arguments:
  -h, --help            Show this help message and exit.
  -p PATH, --path PATH  Path to the output directory.
  -v, --verbose         Set the verbosity level. For example, -vv sets the
                        verbosity level to 2. Default: 0.
  --dry-run             Run the script without creating
                        files and folders. For debugging purposes.The program takes a list of JSON files. For example, we generate the code reference of our AI frameworkGodot Steering Toolkitlike so with the shell:python -m gdscript-docs-maker ~/Repositories/godot-steering-toolkit/src/reference.jsonChangelogThis document lists new features, improvements, changes, and bug fixes in every GDScript docs maker release.GDScript Docs Maker 1.5.1Bug fixesFixedmake buildsetuptools build by usingsrclayoutFixedpip installinstallation workflow (tested locally, PyPi package needs to be updated) - Related issue:#76Fixedgenerate_referencenot finding any file when using -d option (may fixissue #63)GDScript Docs Maker 1.5.0New FeaturesAdded support for constants by @db0.Bug fixesFixed descriptions eating whitespace and flattening nested lists. By @db0.GDScript Docs Maker 1.4.0New FeaturesAdded support for inner classes.Known limitation: the program only supports one nesting level at the moment. This is in part
because by writing them recursively, we would not have enough heading levels (web pages support
6, we are already using 5). Also, we haven't found a project that used that GDScript feature
yet, nesting sub-classes.The shell programget_referencenow supports command line flags.You can specify directories of the Godot project to parse withget_referenceand the-d/--directoryoption.ImprovementsThere is now a-V/--versionflag to print the version number.Improved the shell programget_reference's code to better report errors and work by calling./get_referenceSetter and getter functions now render as a bullet-point list with the member variable they belong to.ChangesHeadings now generate only with leading hashes#instead of being wrapped in hashes.The syntax for tags and other special information now is like JSDoc:@tags - tag1, tag2, tag3.
This differentiates special markup or metadata from the regular docstring. There is also a
discussion toadopt markup like thisin Godot.Bug fixesFixed an error when using the--format hugooption.Added the relative "../" to links to Fixed links leading to 404 pages.Fixed table for setters and getters rendering as plain text with some markdown parsers.Fixed function call error inReferenceCollector.gd.GDScript Docs Maker 1.3.0FeaturesCreate anindex pagewith a table of contents. To do so, use the new
command-line option--make-index. This generates an extraindex.mdfile.You can nowlink between classes, including to specific methods and
properties:Write[ClassName],[ClassName.symbol], or[symbol_in_this_class]and
docs maker will replace it with a link to the corresponding page and
heading.Add support for theclass categorymetadata: this allows you to group classes by categories. Add a line with# category: My Category` in your
class's docstring to register a category for it.Classes now show all ancestors they extend, and the extends list links to
the reference of parent classes.Store and write key project information: name, description, and human-readable
version string.We get them from the Application Settings in your Godot project.For the project version, in 3.2.0, you need to add it yourself as
`application/config/version. It must be with the form "1.0.0". Future or
more recent Godot versions should have this defined by default. Upon
exporting your game, Godot should also use this version number.ImprovementsThe Windowsgenerate_reference.batcommand-line script now supports
command-line flags and arguments. The script also now checks for and prevents
common errors.Removeextendsline if the class doesn't extend any type.Remove properties summary and methods summary if the class respectively
doesn't have public properties or methods.ChangesChanged the default export directory to "export", as we use "dist" to build
the program's pip package itself.GDScript Docs Maker 1.2.1ChangesMove the pip package's configuration tosetup.cfg.The setup now automatically finds packages and data.This improves type checks and imports with mypy.Bug fixesThe tool now outputs regular markdown code blocks instead of hugo shortcodes by default.TheCollector.gdscript you can run from Godot's editor now rebuilds the language server cache so you don't need to restart Godot to rebuild the JSON class data.Fixed an error in markdown conversion when the Godot Language Server generates empty classes in the generated JSON file.If a class doesn't have a name, docs maker will now skip it.GDScript Docs Maker 1.2In developmentFeaturesAdd code highlighting to thehugooutput format.Add--dateand--authorcommand line flags for the hugo front matter output.Add support for theabstracttag, for abstract base classes.Add GDScript code highlighting for the hugo export format.Add support for enums.ImprovementsThe documents now only have 1 empty line betweens paragraphs, headings, etc. instead of 2 to 4.GDScript Docs Maker 1.1FeaturesNew output format for the static website enginehugowith toml front-matter. Use the--format hugooption to select it.New--dry-runcommand-line option to output debug information.Bug fixesUse code blocks for functions instead of inline code.GDScript Docs Maker 1.0This is the initial release of the program. It can collect and generate a code reference from your Godot GDScript projects.FeaturesParses and collects docstrings from GDScript files, using Godot 3.2's Language Server. Outputs the data as JSON.Converts the JSON data to markdown files.Writes methods, static functions, signals, member variables, and class data.Only writes relevant sections. For example, the tool only creates a "Method Descriptions" section if there are methods in the class.Skips built-in callbacks, i.e._process,_input, etc.Skips the constructor,_init, unless it has arguments.Skips private functions and member variables, unless tagged as virtual.Supports tags in the source code with thetags:keyword followed by comma-separated strings, liketags: virtual, deprecated.Currently, the program only takesvirtualinto account, but it does store all the tags.There are two shell scripts for POSIX shells (sh, bash, etc.) and Windows CMD, respectively. Use them to generate your code reference instantly.