Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Synopsis sections are not auto generated. #4189

Closed
2 tasks done
utamori opened this issue Dec 23, 2021 · 11 comments · Fixed by #4450
Closed
2 tasks done

[DOCS] Synopsis sections are not auto generated. #4189

utamori opened this issue Dec 23, 2021 · 11 comments · Fixed by #4450
Assignees
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@utamori
Copy link

utamori commented Dec 23, 2021

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I found that npm create <initializer> behaves the same way as npm init <initializer>, but there seems to be no mention of it in the documentation

Expected Behavior

To have Documentation

Steps To Reproduce

  1. npm v8.3.0
  2. Run npm create vue
  3. It works fine. create-vue

Environment

  • npm:
@utamori utamori added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Dec 23, 2021
@utamori utamori changed the title [DOCS] npm create command is not documented in npm documentation [DOCS] npm create command is not documented Dec 23, 2021
@wraithgar wraithgar changed the title [DOCS] npm create command is not documented [DOCS] Synopsis sections are not auto generated. Jan 18, 2022
@wraithgar
Copy link
Member

The # Synopsis sections of the docs are not being auto-generated like the front matter and the config descriptions.

@wraithgar wraithgar added Documentation documentation related issue Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Jan 18, 2022
@bnb
Copy link
Contributor

bnb commented Feb 15, 2022

this feeels like less of a synopsis issue and more of a "there's no documentation for npm create" 👀

@wraithgar
Copy link
Member

They're aliases. npm init is the real command. If you run npm create -h you will see that the output is all npm init and it says that create is one of its aliases.

@bnb
Copy link
Contributor

bnb commented Feb 15, 2022

that's true, but the docs site has no reference (about it being an alias) to npm create. this creates a weird situation where if someone were to recommend, I use npm create but I go try to figure out how to use it from the docs, I have no path to actually learning about it.

@manekinekko
Copy link
Contributor

Hey, I am trying to send a fix for this issue, but I am confused because I can see the synopsis being generated. Here is the one for npm init:
image

Has this issue been already fixed?

@wraithgar
Copy link
Member

You'll notice that synopsis does not match the output of npm init -h. It was manually generated. The -h output in the cli is auto generated using the usage and params entries in each given command, and should also be the basis for the synopsis in each commands' md file

https://github.com/npm/cli/blob/latest/docs/content/commands/npm-init.md?plain=1#L7-L14

Notice how the configuration section has notes about it being auto generated

https://github.com/npm/cli/blob/latest/docs/content/commands/npm-init.md?plain=1#L146

scripts/config-doc-command.js is what does this, and would need to be extended to also replace the Synopsis section with both the Usage and Options output. And preferrably the aliases too.

@manekinekko
Copy link
Contributor

Oh! I see. I think I get it. I will work on this and send a fix.

manekinekko added a commit to manekinekko/cli that referenced this issue Feb 18, 2022
@manekinekko
Copy link
Contributor

@wraithgar are you ok with me updating all lib/commands/*.js file to include the alias and options entry so they can be printed into the docs/commands/*.md files?

I'd like to validate this change before going over all 66 files. Here is a preview of the change I need to make to each commands files:

image

@wraithgar
Copy link
Member

@manekinekko I don't think you need to edit the js files. It's supposed to work the other way around. The content in the .md files is out of date and the .js files are the ones that we've already gone through and made say what we want, a lot of unneeded context was removed and/or moved to other parts of the .md. The .js files should drive the .md content.

Aliases for any given cmd name can be done like this

> require('./lib/utils/usage.js')('init', '').trim()
'aliases: create, innit'

Usage like this

require('./lib/commands/init.js').usage.map(u => `npm init ${u}`).join('\n')
'npm init [--force|-f|--yes|-y|--scope]\n' +
  'npm init <@scope> (same as `npx <@scope>/create`)\n' +
  'npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)'

The "command options" are already being powered by the .js and populating the Configuration section.

@wraithgar
Copy link
Member

See here how the "run without positional args" part of the old synopsis is already duplicated elsewhere in the description of npm exec https://docs.npmjs.com/cli/v7/commands/npm-exec#description

@manekinekko
Copy link
Contributor

Fantastic! Thanks for pointing this out. I will take care of this then :)

manekinekko added a commit to manekinekko/cli that referenced this issue Feb 21, 2022
manekinekko added a commit to manekinekko/cli that referenced this issue Feb 23, 2022
manekinekko added a commit to manekinekko/cli that referenced this issue Feb 23, 2022
manekinekko added a commit to manekinekko/cli that referenced this issue Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants