Skip to content

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

Open
smolck wants to merge 5 commits into
masterfrom
document-public-api
Open

docs(NvimClient.API): add docstrings for public API#15
smolck wants to merge 5 commits into
masterfrom
document-public-api

Conversation

@smolck

@smolck smolck commented Sep 8, 2021

Copy link
Copy Markdown
Collaborator

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).

Comment thread src/NvimClient.API/NvimAPI.cs
@smolck
smolck force-pushed the document-public-api branch from eb726ea to ccbc026 Compare September 8, 2021 22:26
Comment thread src/NvimClient.API/NvimAPI.cs Outdated
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
@smolck
smolck force-pushed the document-public-api branch from 7eac95e to 9220e9a Compare September 9, 2021 05:28
@lgtm-com

lgtm-com Bot commented Sep 9, 2021

Copy link
Copy Markdown

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

new alerts:

  • 1 for Use of default ToString()

@smolck

smolck commented Sep 9, 2021

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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
@smolck
smolck force-pushed the document-public-api branch from b4c0f1c to ccd2660 Compare September 9, 2021 05:59
@justinmk

justinmk commented Sep 9, 2021

Copy link
Copy Markdown
Member

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.

uiEvents.Select(uiEvent =>
{
var camelCaseName = StringUtil.ConvertToCamelCase(uiEvent.Name, true);
var camelCaseName = $"{StringUtil.ConvertToCamelCase(uiEvent.Name, true)}Event";

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 and others added 2 commits September 9, 2021 09:32
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
@smolck
smolck marked this pull request as ready for review September 10, 2021 19:21
@smolck

smolck commented Sep 10, 2021

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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