Reading Documentation

So I am reading the npm documentation on various npm commands.

I noticed that a lot of documentation they use this weird syntax to describe the functionality of a command. For example:

npm view [<@scope>/]<name>[@<version>] [<field>[.<subfield>]...]

I get the “npm view” part. But what is the whole …

[<@scope>/]<name>[@<version>] [<field>[.<subfield>]...]

part and how exactly do you go about reading this and trying to understand why they write it like that?

You can usually tell by looking at the examples given.

npm view

npm view [<@scope>/]<name>[@<version>] [<field>[.<subfield>]...]

npm view connect === npm view <name>

npm view ronn@0.3.5 dependencies === npm view <name>[@<version>] [<field>]

npm view npm repository.url === npm view <name> [<field>[.<subfield>]...]

Here are the docs on scope.

1 Like

Things in square brackets are optional. It’s a variant on BNF Syntax, though with those extra @'s and slashes, it’s really kind of noisy and not terribly clear. They should have split it up into separate definitions, the way the MySQL docs are written, for example (that example is probably the gnarliest of all commands, so the BNF is pretty big)


Thanks for the answer of explaining what that syntax is. I have been wondering why anyone would write confusing syntax like without any explanation on how to read it.