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

Docstrings should be indented at more than just the first line #22

Open
dhermes opened this issue Sep 27, 2014 · 3 comments
Open

Docstrings should be indented at more than just the first line #22

dhermes opened this issue Sep 27, 2014 · 3 comments

Comments

@dhermes
Copy link

dhermes commented Sep 27, 2014

See
https://gist.github.com/dhermes/85c3a3a464d2cff312ea
for a (super hacky) way to make this work.

Currently, pep8ify takes

def hello_func(name):
  """Prints hello with the name.

  Args:
    name: String, to print.
  """
  print 'Hello %s, nice to meet you.' % (name,)

and turns it into

def hello_func(name):
    """Prints hello with the name.

  Args:
    name: String, to print.
  """
    print 'Hello %s, nice to meet you.' % (name, )

Running indent_docstrings.py on it gives the desired:

def hello_func(name):
    """Prints hello with the name.

    Args:
      name: String, to print.
    """
    print 'Hello %s, nice to meet you.' % (name, )
@spulec
Copy link
Owner

spulec commented Oct 13, 2014

Agreed.

Unfortunately, I don't have much time to spend on this project. If someone has time to make a pull request, I will happily merge.

@dhermes
Copy link
Author

dhermes commented Oct 13, 2014

I'm happy to take a stab. Care to point out the entry point in the code where indenting occurs? Also, do you use ast to parse the tree or something else?

@spulec
Copy link
Owner

spulec commented Oct 21, 2014

We use lib2to3, which is a bit of a wrapper around the ast.

I think this is probably occurring as part of fix_indentation, but I'm not positive.

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

2 participants