https://github.com/blobbybilb/why-doc
why?doc: A simple API docs generator for simple APIs.
https://github.com/blobbybilb/why-doc
Last synced: 5 months ago
JSON representation
why?doc: A simple API docs generator for simple APIs.
- Host: GitHub
- URL: https://github.com/blobbybilb/why-doc
- Owner: blobbybilb
- Created: 2023-06-08T19:42:47.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-26T04:16:29.000Z (about 2 years ago)
- Last Synced: 2024-05-30T02:14:45.775Z (about 2 years ago)
- Language: HTML
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Archived, not general enough >:)
---
# why?doc
A simple API docs generator for simple APIs.
## Usage (example with [Hono](https://hono.dev))
Import:
```ts
import {
genDocs,
WhyDoc,
} from "https://raw.githubusercontent.com/blobbybilb/why-doc/main/doc.ts"
```
Initialize:
```ts
const doc = WhyDoc({
title: "Test API Docs",
basePath: "/api", // optional
})
```
Then, instead of:
```ts
app.get(
"/test",
(c) => c.text("test"),
)
```
Do:
```ts
app.get(
doc("/test", "a simple test"), // returns the path to avoid repeating it
(c) => c.text("test"),
)
```
Add GET and POST Parameters:
```ts
app.post(
doc("/abc", "", {
postParams: {
name: "string",
},
}),
(c) => c.text("Done!"),
)
app.get(
doc("/xyz", "returns the 'name' GET parameter", {
getParams: {
name: "string",
},
}),
(c) => c.text(c.req.query("name")!),
)
```
Finally, generate the docs:
```ts
genDocs() // optionally, pass in a string path to a different output file
app.use("/docs", serveStatic({ path: "./docs.html" })) // serve the static html file however you want
```
And get something like:

## License
GNU LGPLv3