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 window
If the documentation window is already open, it is brought to the front (and restored if
minimized) instead of opening another one. It navigates to the requested page if
moduleName is given, or if it isn't currently showing the requested docs (JS or TS);
otherwise it stays on whatever page it is showing.
hs.docs.show(moduleName, showTS) -> None
| 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 |
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
hs.docs.get(identifier) -> string
| Name | Type | Description |
|---|---|---|
| identifier | string | Dot-separated path such as "hs.camera" or "hs.camera.all" |
null if not foundconsole.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
hs.docs.jsDocsPath() -> string
nullconsole.log(hs.docs.jsDocsPath())
hs.docs.tsDocsPath() -> string
Return the filesystem path to the bundled TypeScript documentation directory
hs.docs.tsDocsPath() -> string
nullconsole.log(hs.docs.tsDocsPath())
hs.docs.apiJSON() -> string
Return the contents of the bundled api.json file
hs.docs.apiJSON() -> string
nullconst data = JSON.parse(hs.docs.apiJSON())
console.log(data.modules.length)