Skip to content

Commit 945528a

Browse files
committed
docs(extensions): use setext headings and label the output block
1 parent 8230926 commit 945528a

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

extensions.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ of them. That makes the manifest below the most important file in an extension:
1515
it is what the CLI reads on startup, and it decides whether your code is loaded
1616
eagerly or only when one of your commands is actually executed.
1717

18-
## Depending on the CLI
18+
Depending on the CLI
19+
--------------------
1920

2021
An extension that imports anything from the CLI — `defineCommand`, `inject`, the
2122
types — needs `nativescript` declared twice:
@@ -63,7 +64,8 @@ searches npm for it when it needs to suggest an extension for an unknown command
6364
> heading; declaring the peer dependency now is what makes an extension ready
6465
> for it.
6566
66-
## Declaring commands
67+
Declaring commands
68+
------------------
6769

6870
Commands are declared in the `commands` key of the `nativescript` key of the
6971
extension's `package.json`. Two shapes are accepted.
@@ -162,7 +164,8 @@ instead. Run any command with `--log trace` to see which installed extensions
162164
still rely on it, or set `NS_DEPRECATIONS=warn` to have those reports printed
163165
as warnings.
164166

165-
## Writing a command module
167+
Writing a command module
168+
------------------------
166169

167170
The recommended shape is a module exporting a `defineCommand` definition (see
168171
[defining-commands.md](defining-commands.md)) — the CLI adapts and registers it
@@ -202,7 +205,8 @@ the command itself, executing that command fails with an error naming the
202205
extension, the command and the module — the entry points at the wrong file, or
203206
the file is not doing what the entry promises.
204207

205-
## Command names
208+
Command names
209+
-------------
206210

207211
Command names use `|` to express hierarchy, so `"hello|world"` is invoked as
208212
`ns hello world`. Prefixing the last segment with `*` marks a default
@@ -233,7 +237,8 @@ An alias is a second entry pointing at the same module:
233237

234238
Both names route to the same module, which is loaded once.
235239

236-
## When two extensions want the same command
240+
When two extensions want the same command
241+
-----------------------------------------
237242

238243
The first extension to claim a command name keeps it; later claimants are
239244
reported with a warning naming both extensions and the command, and their entry
@@ -247,7 +252,8 @@ extension name wins. The exception is `ns extension install`: that invocation
247252
loads the freshly installed extension after all the others, so a conflict it
248253
would win on the next invocation goes the other way that one time.
249254

250-
## Suggesting an extension for an unknown command
255+
Suggesting an extension for an unknown command
256+
----------------------------------------------
251257

252258
When a user types a command the CLI does not know, it searches npm for packages
253259
carrying the `nativescript:extension` keyword, reads the `nativescript.commands`
@@ -260,12 +266,13 @@ default command also matches its short form: an extension declaring
260266
Both manifest shapes participate in this matching. If a match is found, the CLI
261267
tells the user which extension provides the command and how to install it:
262268

263-
```
269+
```text
264270
The command hello world is registered in extension nativescript-hello.
265271
You can install it by executing 'ns extension install nativescript-hello'
266272
```
267273

268-
## Documentation
274+
Documentation
275+
-------------
269276

270277
Point the `docs` key of the `nativescript` key at a directory of `.md` files to
271278
have the CLI's help system pick up the help for your commands.

0 commit comments

Comments
 (0)