Skip to content

Optionally preserve sub-indentation while parsing? #51

Description

@ntjess

Maybe this is unsupportable, but I figured it was worth asking. In my library, metadata for function arguments is stored in the docstring, looking something like this:

def a(x=5):
  """
  :param x: The x parameter
    limits: [0, 5, 10, 15]
  """

Under the hood, I can turn this into a configuration using ConfigParser. However, docstring_parser removes all indentation underneath a parameter. This is a problem for me, since ConfigParser requires multiline values to be indented. The below example doesn't work, since all sub-indentation underneath x is obliterated:

def a(x=5):
  """
  :param x: The x parameter
    limits: [
        0, 5, 10, 15
      ]
  """

docstring_parser.parse() turns x's description into:

The x parameter
limits: [
0, 5, 10, 15
]
^^^ Notice the lack of indentation

Is there some way to optionally use textwrap.dedent instead of strip() during the parsing logic for these cases? Thanks for your consideration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions