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

Formatting for object descriptions. #3

Merged
merged 25 commits into from
Mar 9, 2023
Merged

Conversation

darvil82
Copy link
Owner

@darvil82 darvil82 commented Feb 27, 2023

Allow descriptions of objects, such as Argument's or Command's to have richer information. At the moment, when printing the description on the help view, both the description specified to the argument and the one of the argument type are shown.
This is great, but it would be neat to allow more customization, such as being able to specify formatting semantics, like {@link args.arg1} or {@link cmds.mySubcmd1}.

Example:

Argument.create("test").description("Interesting argument. See also {@link args.arg1}.")

When being printed on the help, this is what would be shown:

--test:
   Interesting argument. See also --arg1.

--arg1 would be shown with the color that represents it. And also, if it had multiple names, these would be shown like --arg1/argument1. Basically the argument representation that is normally shown for each argument.

Formatters ideas:

  • @link: Basically a "reference" to the specified element, as explained above.
  • @from: Inlines the description of the selected element into the current one.

Selectors:

After one of the formatters above is specified, a selector can be used to indicate the element to select (Command, argument, etc.):

  • args.<arg>: The argument with the specified name.
    • <arg>.type: The argument type of the argument. At the moment the description of the type is automatically added. So with this change the user would need to add @from !.type. (! explained below).
  • cmds.<cmd>: The command with the specified name.
    • Since a Command contains more arguments, this can be chained like cmds.<cmd>.args.<arg>.
  • groups.<grp>: The group with the specified name.
  • !: This selects the current element that is generating the description. For example, if the description of an argument named "foo" is set to @link !, this would be equal to @link args.foo.

Syntax ideas:

  • @link:args.arg1, suggested by @fadeoffical. No spaces required but possible problems when parsing if no spaces are present after it, like desc: @link:args.arg1.. The . could cause problems, but we could probably allow {} wrapping to indicate the formatting more explicitly.
  • @link args.arg1, similar to javadocs syntax, though I personally prefer the former!
  • <link=args.arg1>, much easier to parse with the eyes. Will go with this one.

@fadeoffical
Copy link
Contributor

You sure you want to pull into main?

@darvil82
Copy link
Owner Author

Nah it'll be merged into dev. Forgot to change that.

@darvil82 darvil82 changed the base branch from main to dev February 28, 2023 01:04
Copy link
Contributor

@fadeoffical fadeoffical left a comment

Choose a reason for hiding this comment

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

Lgtm! except the two finals.

src/main/java/lanat/helpRepresentation/ArgumentRepr.java Outdated Show resolved Hide resolved
src/main/java/lanat/helpRepresentation/ArgumentRepr.java Outdated Show resolved Hide resolved
@darvil82 darvil82 marked this pull request as ready for review March 9, 2023 02:09
@darvil82 darvil82 merged commit e9efdd2 into dev Mar 9, 2023
@darvil82 darvil82 deleted the feature/descriptions-formatting branch March 11, 2023 04:20
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.

2 participants