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

docs(NvimClient.API): add docstrings for public API #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

smolck
Copy link
Collaborator

@smolck smolck commented Sep 8, 2021

Just a start for now, probably will want to update the generator to generate the docstrings for the public event EventHandler ...s to fully document everything (and silence the warnings when publishing the package).

@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2021

This pull request introduces 1 alert when merging 9220e9a into a66c3b2 - view on LGTM.com

new alerts:

  • 1 for Use of default ToString()

@smolck
Copy link
Collaborator Author

smolck commented Sep 9, 2021

Okay so I've added docs (rough draft) for the UI events; turns out the ui.txt docs for the ui events aren't easily available for use, and I'm not sure if it'd even be worth all the extra work to try and get them (see this commit message).

Ultimately the docs are available (in an arguably better place, for navigation at least) via a quick :help ui-events in nvim, so it's not totally necessary to add them, though I guess it could be nice to have? The thing is it sort of adds noise where as a user of the library you quite possibly just want to know how to use the handler(s), and will read up in the actual nvim help docs if you want to know what the events do/mean (and I mean, if you're dealing with all of this to e.g. make a UI, you should probably read/be reading ui.txt anyways).

Thoughts?

/// // the above handler code will be run.
/// </code>
/// </example>
/// <seealso cref=""{camelCaseName}EventHandler""/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just what I came up with relatively spur-of-the-moment for the docs, lmk if/how it can be improved (and assuming this is how we want to do the docs for these EventHandlers).

@smolck smolck force-pushed the document-public-api branch 4 times, most recently from d88b648 to b4c0f1c Compare September 9, 2021 05:48
I think we'd need to parse the ui.txt help doc if we wanted to get the
documentation from there and use it here, and after testing how it'd
look with the grid_line event docs, I'm not even convinced it'd be a
good idea anyways to use the docs from ui.txt
@justinmk
Copy link
Member

justinmk commented Sep 9, 2021

turns out the ui.txt docs for the ui events aren't easily available for use, and I'm not sure if it'd even be worth all the extra work to try and get them (see this commit message).

yeah I wouldn't bother with that; rather, ui.txt itself should be generated from code, then we could expose it in nvim_get_api().

Thoughts?

I'd say wait until/unless nvim_get_api() exposes the ui.txt docs in a structured way.

@@ -123,11 +123,28 @@ private object GetExtensionType(MessagePackExtendedTypeObject msgPackExtObj)
string.Join("\n",
uiEvents.Select(uiEvent =>
{
var camelCaseName = StringUtil.ConvertToCamelCase(uiEvent.Name, true);
var camelCaseName = $"{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}Event";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var camelCaseName = $"{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}Event";
var camelCaseName = $"{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}UIEvent";

or...

Suggested change
var camelCaseName = $"{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}Event";
var camelCaseName = $"UI{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}Event";

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if I do this I’ll have to modify a few other parts of the code, since this changes the name structure of all the events entirely (from what #11 made them).

I’m fine with doing this if you think it’s a good idea (although there’s something I dislike about all the events having UIEvent at the end of their names, when we could just do api.UIEvents.Put etc. instead), but it’s kinda outside the scope of this PR. Maybe better suited to a follow-up one?

Comment on lines 143 to 144
/// // Now if this event is emitted after attaching the UI,
/// // the above handler code will be run.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move the comment above the handler definition, and...

Suggested change
/// // Now if this event is emitted after attaching the UI,
/// // the above handler code will be run.
/// // This handler will be executed whenever the event is emitted after attaching the UI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 just unresolved this until I move the comment, then I’ll merge.

@smolck smolck marked this pull request as ready for review September 10, 2021 19:21
@smolck
Copy link
Collaborator Author

smolck commented Sep 10, 2021

Okay so some of the rest of the documentation-related warnings, specifically those for certain params not being documented, I'm not quite sure why the docs aren't being generated to fix those. Also, the reason UiTryResize etc. don't have documentation is because they aren't documented in the neovim source.

I don't think any of those things need to block this (and thus a NuGet release); any objections to just going ahead and merging this, putting out a 0.2 nuget release, and then getting the rest of the docs situation sorted out after? Probably starting upstream with adding documentation for the UI events in the source (in ui_events.in.h) and generating ui.txt from that . . .

@justinmk
Copy link
Member

🚢 🇮🇹

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.

2 participants