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

Tabs inserted in numpydoc docstring #52

Closed
sdahdah opened this issue Jan 29, 2022 · 4 comments
Closed

Tabs inserted in numpydoc docstring #52

sdahdah opened this issue Jan 29, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@sdahdah
Copy link
Contributor

sdahdah commented Jan 29, 2022

PEP8 recommends using spaces1, however tabs are inserted when generating docstrings. For example,

def function(a: int, b: float) -> bool:
    """

    Parameters
    ----------
    a: int
<space><space><space><space><tab>
    b: float
<space><space><space><space><tab>

    Returns
    -------
    int
<space><space><space><space><tab>
    float
<space><space><space><space><tab>
    bool
<space><space><space><space><tab>
    """
    if a == int(b):
        c = False
    else:
        c = True
    return c

Is it possible to detect the indentation style from the file or add a configuration option to use spaces here?

(As a side-note, I don't know why three return values were generated when there's only one)

Footnotes

  1. https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

@danymat
Copy link
Owner

danymat commented Jan 30, 2022

Hello, I think that's the best way to go indeed ! It should be very simple and you even can do it ! I will pinpoint the places where there are tabs
I will try to fix them as soon as I can, but if you're quicker, it's cool

@danymat
Copy link
Owner

danymat commented Jan 30, 2022

{ "parameters", "\t%s ($1): $1", { type = { "func" } } },
{ { "identifier", "type" }, "\t%s (%s): $1", { required = "typed_parameters", type = { "func" } } },
{ "attributes", "\t%s: $1", { before_first_item = { "", "Attributes: " } } },
{ "has_return", "", { type = { "func" } } },
{ "has_return", "Returns:", { type = { "func" } } },
{ "has_return", "\t$1", { type = { "func" } } },
{ nil, '"""' },
},
numpydoc = {
{ nil, '""" $1 """', { no_results = true, type = { "class", "func" } } },
{ nil, '"""$1', { no_results = true, type = { "file" } } },
{ nil, "", { no_results = true, type = { "file" } } },
{ nil, "$1", { no_results = true, type = { "file" } } },
{ nil, '"""', { no_results = true, type = { "file" } } },
{ nil, "", { no_results = true, type = { "file" } } },
{ nil, "# $1", { no_results = true, type = { "type" } } },
{ nil, '"""$1' },
{ "has_identifier", "", { type = { "func" } } },
{ "has_identifier", "Parameters", { type = { "func" } } },
{ "has_identifier", "----------", { type = { "func" } } },
{
"parameters",
"%s: $1",
{ after_each = "\t$1", type = { "func" } },
},
{
{ "identifier", "type" },
"%s: %s",
{ after_each = "\t$1", required = "typed_parameters", type = { "func" } },
},
{ "attributes", "%s: $1", { before_first_item = { "", "Attributes", "----------" } } },
{ "has_return", "", { type = { "func" } } },
{ "has_return", "Returns", { type = { "func" } } },
{ "has_return", "-------", { type = { "func" } } },
{
"return_type",
"%s",
{ after_each = "\t$1" },
},
{
"return_statement",
"%s : $1",
{ after_each = "\t$1" },
},
{
"anonymous_return",
"%s",
{ after_each = "\t$1" },
},

@danymat danymat added the enhancement New feature or request label Jan 30, 2022
@danymat
Copy link
Owner

danymat commented Jan 30, 2022

Hello, can you try again ? There should be now spaces instead of tabs

@danymat danymat closed this as completed Jan 30, 2022
@sdahdah
Copy link
Contributor Author

sdahdah commented Jan 30, 2022

It works great now, thanks for getting to that so quickly!

@danymat danymat reopened this Jan 30, 2022
@danymat danymat closed this as completed Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants