https://github.com/crhntr/templatedocumentation
Go HTML Template Documentation
https://github.com/crhntr/templatedocumentation
documentation go template
Last synced: 4 months ago
JSON representation
Go HTML Template Documentation
- Host: GitHub
- URL: https://github.com/crhntr/templatedocumentation
- Owner: crhntr
- License: mit
- Created: 2024-07-15T22:58:49.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-16T18:07:13.000Z (11 months ago)
- Last Synced: 2025-02-18T11:58:04.061Z (4 months ago)
- Topics: documentation, go, template
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Generate HTTP Template Documentation for your Project [](https://pkg.go.dev/github.com/crhntr/templatedocumentation)
## Usage
1. Create a main package to serve the documentation
`mkdir -p ./cmd/template-docs`
2. Create a `main.go` file in the `./cmd/template-docs` directory
```go
package mainimport (
"cmp"
_ "embed"
"html/template"
"log"
"net/http"
"os""github.com/crhntr/templatedocumentation"
"example.com/org/module/internal/hypertext" // replace with your module
)func main() {
h := templatedocumentation.Handler(func() (*template.Template, template.FuncMap, error) {
fn := hypertext.Functions()
ts, err := hypertext.Template()
return ts, fn, err
})
log.Fatal(http.ListenAndServe(":"+cmp.Or(os.Getenv("DOCS_PORT"), "8200"), h))
}
```3. Run the server
`go run ./cmd/template-docs`
4. Navigate to `http://localhost:8200` to view the documentation.