Godoc generates a formatted PDF of your code's documentation also name docstring. It allows you to have a documentation that's easy to read / access for every developer that can work on your project.
When I was working on an API rest for a personal project, I came up against the problem of documentation. Well-known solutions like swagger exist. Nowadays, however, public documentation can be a source of vulnerabilities. To protect my infrastructure from fuzzing, I set myself the challenge of creating a PDF documentation generated from the docstring of any project.
This is how godoc was born. And this is also why for the moment, this README really looks like the one from a cool project named Swaggo.
-
Add comments to your source code, See Declarative Comments Format.
-
Install godoc by using:
go install github.com/mitsuaaki/godoc/cmd/godoc@latest
To build from source you need Go (1.22 or newer).
Or download a pre-compiled binary from the release page.
- Run
godoc init
in the root folder. This will parse your comments and generate the required files.
godoc init
For the moment, godoc only supports a few languages.
If you want to add support for another language, you can create a new issue or a pull request.
Also, only testing purposes command or available:
godoc test-generate <options>
godoc test-scan <options>
If you want to contribute to the PDF part, that would be great.
You can find the code in the following folder: pdf.
(Help me, it's really pain in the ass however it's not that hard just boring)
At the moment, godoc only supports Go.
You can see some examples in the example folder.
If you want to add support for another language, you can create a new issue or a pull request.
Annotation | Description | Example |
---|---|---|
project-title | Required. The title of the project. | // @title Godoc Example |
project-version | Required. Provides the version of the project. | // @version 1.0 |
project-description | A short description of the application. | // @description This is a cool desc |
Annotation | Description | Example |
---|---|---|
file-description | A short description of the file. | // @description This file contains... |
Annotation | Description | Example |
---|---|---|
description | A short description of the function. | // @description This function does... |
param | Description of a parameter. | // @param a - type - This is the first param |
return | Description of the return value. | // @return The result of the addition |
complexity | The complexity of the function. | // @complexity O(n) |
example | Example code for using the function. | // @example functionExample() |
author | Author of the function. | // @author John Doe |