https://github.com/dimitarpetrov/godoc-generate
Default godoc generator - make your first steps towards better code documentation
https://github.com/dimitarpetrov/godoc-generate
code-comments code-quality documentation documentation-generator generator go godoc golang
Last synced: 2 months ago
JSON representation
Default godoc generator - make your first steps towards better code documentation
- Host: GitHub
- URL: https://github.com/dimitarpetrov/godoc-generate
- Owner: DimitarPetrov
- License: mit
- Created: 2021-09-07T13:01:12.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-23T15:33:28.000Z (over 3 years ago)
- Last Synced: 2025-03-26T10:21:20.515Z (3 months ago)
- Topics: code-comments, code-quality, documentation, documentation-generator, generator, go, godoc, golang
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 21
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# godoc-generate
[](https://goreportcard.com/report/github.com/DimitarPetrov/godoc-generate)
## Overview
`godoc-generate` is a simple command line tool that generates default godoc comments on all **exported** `types`, `functions`, `consts` and `vars` in the current working directory and recursively for all subdirectories.
The godoc comments looks like this:
```
// %s missing godoc.
```Where `%s` is the name of the type/func/const/var.
> NOTE: The comment format can be overridden via the `--format` flag.
## Installation
#### Installing from Source
```
go install github.com/DimitarPetrov/godoc-generate@latest
```## Demonstration
Let's say you have a simple `Multiply` function without `godoc`:
```go
func Multiply(a,b int) int {
return a * b
}
```It is exported, therefore it is part of the package's interface. It is ideomatic to add godoc on everything exported in your package.
If you run `godoc-genenrate` the code will be rewritten the following way:
```go
// Multiply missing godoc.
func Multiply(a, b int) int {
return a * b
}
```This way you are safe to add a linter enforcing godoc and migrate all legacy code gradually.