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

Be able to translate docment to numpy docstring #493

Open
Jaume-JCI opened this issue Oct 17, 2022 · 0 comments
Open

Be able to translate docment to numpy docstring #493

Jaume-JCI opened this issue Oct 17, 2022 · 0 comments

Comments

@Jaume-JCI
Copy link

I don't know whether to create this issue here or in the nbdev repo. As an enhancement proposal, it would be great to be able to generate .py modules with numpy docstrings, from the original notebooks that have docments, and then convert back if someone edits the docstring in the .py module, something like:

Original notebook:

def add (x: int, # First summand.
         y: int, # Second summand.
         ): int # Result of adding `x` and `y`.
    "Adds x and y"
    return a+b

Generated .py module:

def add (x: int,
         y: int,
         ): int
    """
    Adds x and y.
    
    Parameters
    ----------
    x: int
        First summand.
    y: int
        Second summand.
    Returns
    -------
    int
        Result of adding `x` and `y`.
    """
    return a+b

We modify the docstring in the .py module:

def add (x: int,
         y: int,
         ): int
    """
    Adds integer x and integer y.
    
    Parameters
    ----------
    x: int
        First number to add.
    y: int
        Second number to add.
    Returns
    -------
    int
        Result of adding `x` and `y`.
    """
    return a+b

Convert back to notebook with docment syntax:

def add (x: int, # First number to add.
         y: int, # Second number to add.
         ): int # Result of adding `x` and `y`.
    "Adds integer x and integer y."
    return a+b    

It seems this is not difficult to do with the current functionality, is this something that would be interesting for the team?
Thank you very much for your awesome work.

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

No branches or pull requests

1 participant