hs.docs
Modulehs.docs
Offline API documentation browser
Browse and query the Hammerspoon 2 API documentation from within the app.
hs.docs.show() opens an hs.ui.webview window with the JS or TypeScript docs.
hs.docs.get() returns formatted plain-text documentation from the bundled api.json.
Properties
This module has no properties.
Methods
hs.docs.show(moduleName, showTS) -> None
Open the Hammerspoon 2 API documentation in a new window
Declaration
hs.docs.show(moduleName, showTS) -> None
Parameters
| Name | Type | Description |
|---|---|---|
| moduleName | string | Optional module to navigate to directly (e.g. `"hs.application"`). Omit to open the index page. |
| showTS | boolean | Pass `true` to show TypeScript docs instead of JS docs |
Returns
None
Example
hs.docs.show()
hs.docs.show("hs.application")
hs.docs.show("hs.application", true)
hs.docs.get(identifier) -> string
Return documentation for a module, method, or property
Declaration
hs.docs.get(identifier) -> string
Parameters
| Name | Type | Description |
|---|---|---|
| identifier | string | Dot-separated path such as `"hs.camera"` or `"hs.camera.all"` |
Returns
string
A plain-text summary of the item, or `null` if not found
Example
console.log(hs.docs.get("hs.application"))
console.log(hs.docs.get("hs.camera.all"))
hs.docs.jsDocsPath() -> string
Return the filesystem path to the bundled JS documentation directory
Declaration
hs.docs.jsDocsPath() -> string
Returns
string
Absolute path to the JS docs folder inside the app bundle, or `null`
Example
console.log(hs.docs.jsDocsPath())
hs.docs.tsDocsPath() -> string
Return the filesystem path to the bundled TypeScript documentation directory
Declaration
hs.docs.tsDocsPath() -> string
Returns
string
Absolute path to the TS docs folder inside the app bundle, or `null`
Example
console.log(hs.docs.tsDocsPath())
hs.docs.apiJSON() -> string
Return the contents of the bundled `api.json` file
Declaration
hs.docs.apiJSON() -> string
Returns
string
JSON string containing the full API specification, or `null`
Example
const data = JSON.parse(hs.docs.apiJSON())
console.log(data.modules.length)