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

Refactor documentation tags and makedoc parsing #40

Open
jmooring opened this issue Jun 24, 2020 · 1 comment
Open

Refactor documentation tags and makedoc parsing #40

jmooring opened this issue Jun 24, 2020 · 1 comment
Labels
documentation Related to documentation

Comments

@jmooring
Copy link
Owner

jmooring commented Jun 24, 2020

General thoughts:

  1. Add support for a @deprecated tag (see Create deprecation process and mechanism #38)
  2. Think carefully about whether or not it makes sense to specify types for inputs and output. With Bash, all args are strings, and by definition output is also a string. I still think it makes sense to specify int if the function is expecting a string representation of an integer.
  3. Currently I use @returns, but this is misleading. Bash functions don't return anything. Here's what Bash functions can do when invoked through command substitution.
  • Set exit status
  • Print something to stdout
  • Print something to stderr

Maybe the function headers should be more specific. For example:

@param string $foo
  The name of the foo.
@param string $bar (optional)
  The name of the bar.

Note the use of the parenthetical optional descriptor.

@exit_status
  0 upon success, 1 upon failure.
@prints string $quz
  The output of the function.

Most functions print to stdout, but a few print to stderr (die, error, iform, and warn). A couple of options:

  1. Add a parenthetical descriptor: @prints string $quz (stderr)
  2. Since printing by definition creates a string, replace the type with either stdout or stderr: @prints stdout $quz

I'm leaning towards option 1. Even though printing always produces a string, specifying int is still valuable to indicate that the output is a string representation of an integer. Additionally, option 1 is inline with how we specify optional params.

If the function doesn't print anything, leave this section out.

@global string $baz 
  The name of the baz.

This should probably be directly beneath the params section.

When a function is invoked via command substitution it is executed with a subshell. Within a subshell, a function:

  • Can Create a global variable, but it will not be visible to the parent shell.
  • Can Read a global variable created in the parent shell.
  • Can Update a global variable created in the parent shell, but the parent shell will never see the new value.
  • Can Delete (unset) a global variable created in the parent shell, but it will continue to exist in the parent shell.

It would be good to document how a function acts on a particular global variable, meaning, does it Create, Read, Update, or Delete (CRUD)?

Given that most functions are currently (see #41) invoked via command substitution, the most likely or common action would be Read. However, the bfl::declare_ansi_escape_sequences creates a number of global variables.

Perhaps, like @params and @prints, add a parenthetical descriptor to indicate the nature of the interaction:

@global string $baz (create)
@global string $baz (read)
@global string $baz (update)
@global string $baz (delete)

Deprecation. See #38.

@deprecated
  This function has been replaced by foo.
@jmooring jmooring changed the title Refactor documentation tags (@foo) and makedoc parsing Refactor documentation tags and makedoc parsing Jun 24, 2020
@jmooring jmooring added the documentation Related to documentation label Jun 24, 2020
@jmooring jmooring added this to Backlog in Bash Function Library Jun 24, 2020
@jmooring
Copy link
Owner Author

Also need to update samples, examples, and Coding Standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation
Projects
Development

No branches or pull requests

1 participant