API Docs

hs.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
None
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"
string
A plain-text summary of the item, or null if not found
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

hs.docs.jsDocsPath() -> string
string
Absolute path to the JS docs folder inside the app bundle, or null
console.log(hs.docs.jsDocsPath())

hs.docs.tsDocsPath() -> string

Return the filesystem path to the bundled TypeScript documentation directory

hs.docs.tsDocsPath() -> string
string
Absolute path to the TS docs folder inside the app bundle, or null
console.log(hs.docs.tsDocsPath())

hs.docs.apiJSON() -> string

Return the contents of the bundled api.json file

hs.docs.apiJSON() -> string
string
JSON string containing the full API specification, or null
const data = JSON.parse(hs.docs.apiJSON())
console.log(data.modules.length)