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

Markbind help: update output to match userguide #550

Closed
wants to merge 7 commits into from
Closed

Markbind help: update output to match userguide #550

wants to merge 7 commits into from

Conversation

JYL123
Copy link
Contributor

@JYL123 JYL123 commented Jan 5, 2019

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X ] Enhancement to an existing feature

What is the rationale for this request?
Fixes #535

What changes did you make? (Give an overview)
Update index.js command descriptions to match the updates in user guide. The modified command overview is as follows from terminal:

commands

Is there anything you'd like reviewers to focus on?

Testing instructions:
Run markbind -h from terminal

index.js Outdated
.option('-p, --port <port>', 'port for server to listen on (Default is 8080)')
.option('-s, --site-config <file>', 'specify the site config file (default: site.json)')
.option('-p <port>, --port <port>', 'port for server to listen on (Default is 8080)')
.option('-s <file>, --site-config <file>', 'specify the site config file (default: site.json)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the options: -p and -s do not have an effect, and the long options --port and --site-config are not recognised.

The reason is because the library we are using for the CLI, commander.js, parses the first argument to .option as a list of flags:

The flags string should contain both the short and long flags, separated by comma, a pipe or space.

I don't think we can make this specific change without breaking the CLI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Xenonym, thanks for the explanation. I should have tested it myself. I got it now. Then I will remove my modification.

index.js Outdated
@@ -172,6 +172,7 @@ program

program
.command('build [root] [output]')
.option('<output>', 'put the generated files in the specified directory')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with earlier, commander.js expects a list of flags as the first argument to .option(). Passing in anything else doesn't seem to have meaningful results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out again. I will remove this line as well. For this issue, is there any other parts that i have missed which is supposed to be done?

@Xenonym
Copy link
Contributor

Xenonym commented Jan 5, 2019

@JYL123 comparing between the user guide and the output of markbind <command> -h, these are the differences I notice:

  1. The commands are listed in the user guide in alphabetical order, but not so in markbind. We could alphabetise the commands in index.js to match the user guide.
  2. Optional arguments are denoted with [] in markbind eg. --baseUrl [baseUrl] but marked with <> in the user guide. Since we cannot change the flag description without changing the behaviour of the CLI, we should probably change the user guide to match instead.

@yamgent
Copy link
Member

yamgent commented Jan 6, 2019

@Xenonym excellent review, good work. 👍

@damithc just checking, how much of the matching were you looking for when you created #535? Were you expecting a close match like this:

$ markbind --help

  ...

  Commands:

  build [options] [root] [output]  Generates the site to the directory named _site
                                   in the current directory.
  deploy                           Deploys the site to the repo's Github pages by 
                                   pushing everything in the generated site (default 
                                   dir: _site) to the gh-pages branch of the current 
                                   git working directory's remote repo. 

  ...

@damithc
Copy link
Contributor

damithc commented Jan 6, 2019

@damithc just checking, how much of the matching were you looking for when you created #535?

It's better to be as close as possible, right? For example, use the same notation for options markbind build [<OPTIONS>].
Perhaps we can standardize similar to javadocs. Example: In the user guide, the first paragraph of the description is 1-2 sentence overview of the command/parameter that will be reused in the CLI help. Further details can be in subsequent paragraphs.

@Xenonym
Copy link
Contributor

Xenonym commented Jan 6, 2019

It's better to be as close as possible, right? For example, use the same notation for options markbind build [<OPTIONS>].

The description in the CLI is actually parsed by commander.js to determine what arguments the command takes. I don't think we can change it without breaking the commands.

@damithc
Copy link
Contributor

damithc commented Jan 6, 2019

The description in the CLI is actually parsed by commander.js to determine what arguments the command takes. I don't think we can change it without breaking the commands.

I see. I don't mind if the user guide is changed to match the format used by CLI, if that format is good enough. In the user guide, I was trying to follow the format used by Git documentation.

@JYL123
Copy link
Contributor Author

JYL123 commented Jan 6, 2019

Hi, thanks for clarifying this issue. is it okay that I make the following changes:

  1. for user guide, refer to this Git documentation, can I remove <> for OPTIONS, root, output and leave the rest as it is? because from the documentation, I see <> is used for extra values added within []. So for example, my imagination for build is :
build Command
Format: markbind build [OPTIONS]

OPTIONS:
* output
...
* root output
...
* --baseUrl <base>
...
  1. for index.js, I will add Description from user guide for each command description, and add option descriptions from user guide, such as <output> Put the generated files in the specified directory, in flag descriptions.

Please correct me if anything is wrong or not appropriate. Thanks in advance.

@damithc
Copy link
Contributor

damithc commented Jan 6, 2019

  1. because from the documentation, I see <> is used for extra values added within [].

It looks like <> is used to indicate a placeholder where a value is expected. e.g., <root> means it it expects a value such as c:\ whereas options without <> e.g., --base-url are keywords that should be repeated exactly as they are. What do you think?

@JYL123
Copy link
Contributor Author

JYL123 commented Jan 6, 2019

Thanks prof. I see. It makes sense. Then I think the user guide is good. I will undo my change to the user guide, namely keep the user guide as follows:

Format:  markbind build [<OPTIONS>]
...
OPTIONS:
* <output>
...
* <root> <output>
...

And change the descriptions in index.js as the comment above.

@damithc
Copy link
Contributor

damithc commented Jan 6, 2019

Thanks prof. I see. It makes sense. Then I think the user guide is good. I will undo my change to the user guide, namely keep the user guide as follows:

Format:  markbind build [<OPTIONS>]
...
OPTIONS:
* <output>
...
* <root> <output>
...

And change the descriptions in index.js as the comment above.

Got it. I'll leave the senior devs to make the final decision w.r.t. the exact format to follow.

@yamgent
Copy link
Member

yamgent commented Jan 7, 2019

  1. for index.js, I will add Description from user guide for each command description, and add option descriptions from user guide, such as <output> Put the generated files in the specified directory, in flag descriptions.

Is that actually possible with commander.js? I don't see a way of specifying the description for the compulsory arguments...

Also, I am in favour of such a format:

Example: In the user guide, the first paragraph of the description is 1-2 sentence overview of the command/parameter that will be reused in the CLI help. Further details can be in subsequent paragraphs.

Basically, the help description in the CLI should be as short as possible (which is what we have currently). The user guide should also have the short description, but then it will be followed by the details for the command.

For example, the help description for markbind build should be a single sentence summary:

$ markbind build --help

  Usage: build [options] [root] [output]

  Builds the website


  Options:

But the user guide should contain the single sentence summary + additional description of what it does:


build Command

Format: markbind build [<OPTIONS>]

Description: Builds the website.

Generates the site to the directory named _site in the current directory.

...

EDIT: Edited a bit of the format.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For markbind build, update the user guide's description of --baseUrl to match what you have here (e.g. in the user guide, it mentions "with the give" rather than "with the given").
  2. For markbind serve, update the description of the options in index.js to the first statement in the user guide.
  3. Please add the following code, such that when markbind --help is invoked, it says "Usage: markbind " instead of "Usage: index ":
diff --git a/index.js b/index.js
index 33ccb4f..8bd0007 100755
--- a/index.js
+++ b/index.js
@@ -29,6 +29,7 @@ function printHeader() {
 }

 program
+  .name('markbind')
   .allowUnknownOption()
   .usage(' <command>');

@@ -65,7 +69,9 @@ MarkBind Command Line Interface (CLI) can be run in the following ways:

**Format:** `markbind init [<OPTIONS>]`

**Description:** Initializes a directory into a MarkBind site by creating a skeleton structure for the website which includes a `index.md` and a `site.json`.
**Description:** Init a markbind website project.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markbind -> MarkBind. (this should also be modified in index.js)

@@ -82,7 +88,9 @@ MarkBind Command Line Interface (CLI) can be run in the following ways:

**Format:** `markbind serve [<OPTIONS>]`

**Description:** Does the following steps:
**Description:** Build then serve a website from a directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build then serve a website from a directory. (this should also be modified in index.js)

While it is true that MarkBind does build the site into _site/, techincally, they don't really have to do that (i.e. we could have built the files in a temporary hidden directory rather than modifying _site/, because markbind serve is not really supposed to do building anyway). Therefore, I stroke off the "Build then" portion because that is too much unnecessary details.

The steps that follow (i.e. the "Does the following steps:" part) can stay however.

index.js Outdated

program
.command('deploy')
.description('deploy the site to the repo\'s Github pages')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github -> GitHub. site -> website. (this should also be modified in cliCommands.md)

@yamgent
Copy link
Member

yamgent commented Jan 8, 2019

There are two other issues that I have spotted.

  1. <arg>: compulsory argument. [arg] = optional argument. The user guide is not consistent on this front.
  2. Options are different from arguments. Options have a flag (e.g. -n or --no-open). Arguments do not have a flag. The user guide is not making the distinction clear.

@JYL123
Copy link
Contributor Author

JYL123 commented Jan 8, 2019

@yamgent Thanks for the review!

@JYL123 JYL123 closed this Jan 8, 2019
@JYL123 JYL123 reopened this Jan 8, 2019
Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We don't use merge commits inside PR (we want to keep the repo history as clean as possible). So the merge commit Merge branch 'master' into update-help-to-match-userguide shouldn't appear in this PR.

    A rebase should be done to resolve conflicts instead. See this guide for details.

@@ -69,7 +69,7 @@ Deploys the site to the repo's Github pages by pushing everything in the generat

**Format:** `markbind init [<OPTIONS>]`

**Description:** Init a markbind website project.
**Description:** Init a Markbind website project.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The B needs to be capitalized as well, that is how we brand our project. (i.e. MarkBind, not Markbind)

* `-o, --one-page [file]`<br>
Render and serve only a single page from your website.<br>
{{ icon_example }} `--one-page guide/index.md`
* `-p [port]`, `--port [port]`<br>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it the wrong way round. :P

Things like [root] are the optional arguments (users can omit root when using markbind serve). They should be wrapped with [].

Things like <port> are the compulsory arguments (users must specify a port number when using -p). They should be wrapped with <>.

Most of the commands and options have this issue as well, please do rectify them, thanks!

@JYL123 JYL123 closed this Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

markbind help: update output to match userguide
4 participants