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

Improve parsing & formatting of help page descriptions #680

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Nov 13, 2024

📝 Description

This pull request resolves various issues that caused help page argument descriptions to not be properly parsed, leading to malformed outputs like:

--label (required): A unique.

✔️ How to Test

The following test steps assume you have pulled down this PR locally and run make install.

Unit Testing

make testunit

Manual Testing

  1. In your linode-cli project directory, create a new dump_descriptions.py file with the following contents:
from linodecli import CLI
from rich.console import Console

from linodecli.baked.request import OpenAPIRequestArg

console = Console()

cli = CLI("0.0.0.dev", "https://localhost", skip_config=True)

cli.load_baked()

for op_name, op in cli.ops.items():
    for action_name, action in op.items():
        console.print(f"[green b]{op_name} {action_name}[/green b]: {action.summary}")

        if action.request is None:
            console.print()
            continue

        for arg in action.request.attrs:
            if not isinstance(arg, OpenAPIRequestArg):
                continue

            console.print(f"\t[blue b]--{arg.name}[/blue b]: {arg.description_rich}")

        console.print()
  1. Run python3 dump_descriptions.py.
  2. Manually review the output and ensure all descriptions are readable and do not have any formatting issues.

@lgarber-akamai lgarber-akamai added the bugfix for any bug fixes in the changelog. label Nov 13, 2024
@lgarber-akamai lgarber-akamai changed the title Resolve issue with malformed help page descriptions Improve parsing & formatting of help page descriptions Nov 13, 2024
@lgarber-akamai lgarber-akamai marked this pull request as ready for review November 13, 2024 20:03
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner November 13, 2024 20:03
@lgarber-akamai lgarber-akamai requested review from zliang-akamai and ezilber-akamai and removed request for a team November 13, 2024 20:03
# Ensure the summary has punctuation
self.summary = operation.summary.rstrip(".") + "."

self.description_rich, self.description = simplify_description(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't consume OpenAPIOperation(...).description currently but I figured it'd be good to future-proof 🙂

@@ -5,15 +5,15 @@
import functools
Copy link
Contributor Author

@lgarber-akamai lgarber-akamai Nov 13, 2024

Choose a reason for hiding this comment

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

The changes in this file originated in #639, which provides a bit more context for why they were made.

@lgarber-akamai lgarber-akamai added improvement for improvements in existing functionality in the changelog. and removed bugfix for any bug fixes in the changelog. labels Nov 13, 2024
Copy link
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! Unit tests are passing locally and manual test looked good too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement for improvements in existing functionality in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants