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

Add sections support for generating partial docstrings #201

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ColinKennedy
Copy link
Contributor

@ColinKennedy ColinKennedy commented Sep 2, 2024

closes #165

This PR adds (Lua API only) support for generating certain sections of a user's docstring. The basic functionality for generator.lua is like this

  • (default behavior) if no sections are given, the user wants to generate the whole docstring

  • if sections are given...

    • we assume that the user wants to add part of a docstring at the current cursor row (and not the usual spot)
    • A given section like "yield" will match all "yield-related" sections
    • any section that is not found is excluded from the docstring output

Extra Notes

Locators Are More Important Now

This PR did expose a slight flaw in the currently supported languages though. Normally Neogen assumes that the user's cursor is directly on the node that they want to generate from. But since this new PR generates docstrings from the cursor position, locators are now more important than they used to be. A couple languages have one already, this PR adds one for Python. Any other language will likely need a locator too.

Until all languages have a locator + unittests, I'm thinking we should fail early if the user provides sections and the given language doesn't provide an explicit locator (it's not in the PR currently but I can add it). What do you think?

Maybe We Should Add at=

The current PR logic assumes that the docstring must generate under the cursor. I think we could expose this behavior as a Lua parameter. The new logic could be

  • If sections is not given, don't generate under the cursor (the current, default behavior)
  • If sections is given and at is not set, assume it is at the user's cursor
  • If at is given, use that cursor location

What do you think?

@ColinKennedy ColinKennedy force-pushed the issues/165-add_explicit_sections branch 2 times, most recently from a2bfe75 to cdeb71d Compare September 2, 2024 06:17
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

Successfully merging this pull request may close these issues.

Allow generating explicit sections
1 participant