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

the help format parsing is not consistent #113

Closed
OrHayat opened this issue Feb 25, 2024 · 2 comments
Closed

the help format parsing is not consistent #113

OrHayat opened this issue Feb 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@OrHayat
Copy link

OrHayat commented Feb 25, 2024

the rst parser parse only some parse of the pydoc
also it accept rich tags in some parts and no

import cyclopts
app=cyclopts.App(help_format="rst")

@app.command
def div(x:int,y:int)->int:
    """My application **[red]summary[/red]**.

    We can do RST things like have bold text**.
    More words in this paragraph.

    This is a new paragraph with some bulletpoints below:

    * bullet point 1.
    * bullet point 2.
    
    Args:
        x (int): 
        y (int): number [red bold]must to not be 0[/red bold]

    Returns:
        int: x/y

    """    
    print(x/y)

if __name__=="__main__":
    app()

seems like this is not consistent on some parts of the help u can use md/rst parser and some of them can be modified with rich tags
and the usage sometimes can be modified with rich tags and sometimes not.
i am not sure what is the best fix for this issue would be

for example

orhayat:~/cyclopts (main) is 📦 v0.0.0 via 🐍 v3.10.12
 > python3 rst.py  -h
Usage: rst.py COMMAND

╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ div        My application **summary**.                                                                                                                                 │
│ --help,-h  Display this message and exit.                                                                                                                              │
│ --version  Display application version.                                                                                                                                │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

orhayat:~/cyclopts (main) is 📦 v0.0.0 via 🐍 v3.10.12
 > clear

orhayat:~/cyclopts (main) is 📦 v0.0.0 via 🐍 v3.10.12
 > python3 rst.py div -h
Usage: rst.py div [ARGS] [OPTIONS]

My application [red]summary[/red].

We can do RST things like have bold text**. More words in this paragraph.

This is a new paragraph with some bulletpoints below:

 • bullet point 1.
 • bullet point 2.

╭─ Parameters ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  X,--x  [required]                                                                                                                                                   │
│ *  Y,--y  number must to not be 0 [required]                                                                                                                           │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@BrianPugh
Copy link
Owner

There's definitely some inconsistencies; to be absolutely concrete, uploading some screenshots from your example code:

import cyclopts

app = cyclopts.App(help_format="rst")


@app.command
def div(x: int, y: int) -> int:
    """My application **[red]summary[/red]**.

    We can do RST things like have **bold text**.
    More words in this paragraph.

    This is a new paragraph with some bulletpoints below:

    * bullet point 1.
    * bullet point 2.

    Args:
        x (int):
        y (int): number [red bold]must to not be 0[/red bold]

    Returns:
        int: x/y

    """
    print(x / y)


if __name__ == "__main__":
    app()

Screenshot 2024-02-25 at 1 50 16 PM

I will be investigating, but would definitely like input on expected behavior. I never explicitly thought about people using rich markup in their text. I think it would be good to allow this where ever possible, but here it's causing some inconsistent behavior with rich-rst.

Currently I believe I'm only taking into account the format when rendering the main docstring; I should also take it into account when rendering "short description" and other related areas.

@BrianPugh
Copy link
Owner

#166 has been released with v2.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants