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: improve general methods documentation #386

Closed
8 of 9 tasks
Valentin271 opened this issue Aug 7, 2023 · 16 comments · Fixed by #696
Closed
8 of 9 tasks

Docs: improve general methods documentation #386

Valentin271 opened this issue Aug 7, 2023 · 16 comments · Fixed by #696
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@Valentin271
Copy link
Member

Valentin271 commented Aug 7, 2023

Problem

There is not enough documentation in the widgets' methods (and other relative elements such as Title or Padding). While most of them are simple and require almost no documentation, some other can be ambiguous.

This was a major pain point for me while discovering the library (as a user and as a contributor).

Solution

Add documentation

Alternatives

None

Additional context

I'm totally down to work on it, I just want to advertise this work for users and possibly interested contributors.

Elements missing documentation, grouped by widget :

There are other elements that need documentation, but I think they can be addressed later in an other issue.


Would it be useful to warn (and deny, once completed) on missing doc? See https://doc.rust-lang.org/rustdoc/lints.html#missing_docs

@Valentin271 Valentin271 added the enhancement New feature or request label Aug 7, 2023
@Valentin271
Copy link
Member Author

Also, I think documentation and maybe good first issue are good labels here. Thanks

@joshka joshka added the good first issue Good for newcomers label Aug 7, 2023
@joshka
Copy link
Member

joshka commented Aug 7, 2023

Would it be useful to warn (and deny, once completed) on missing doc? See https://doc.rust-lang.org/rustdoc/lints.html#missing_docs

Yes. Definitely! (Probably worth doing per file once they are documented well)

@joshka joshka added the documentation Improvements or additions to documentation label Aug 7, 2023
@joshka
Copy link
Member

joshka commented Aug 7, 2023

P.S. I recommend using an LLM (e.g. OpenAI / Llama / Claude) to help make this quicker to implement. Obviously validate the output and don't just accept AI hallucinations as gospel :)

Perhaps add some general doc guidelines to this issue or point to some existing ones if you're aware of them.
Some key points I'd worry about are (please add some more if you have them):

  • keep line length to 100 chars (to make it easy to maintain) - the vscode rewrap extension is good for this
  • first line is summary, second line blank, third onwards is more detail.
  • the main type doc comment should talk about the general features that the widget supports and introduce the concepts pointing to the various methods. Focus on interaction with various features and giving enough information that helps understand why you might want something. Also point out alternates
  • any example code is as simple as possible

Also, another way to contribute to the documentation is to improve the examples so they cover each feature a little better. the examples are scraped automatically to provide examples in the docs page (use cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples --all-features --open or run bacon and press d). A recently updated example is the block example, which gives the following output without any changes to the block's comments:

image

I've been thinking a bit about how and whether to add images to the doc comments. Like perhaps it would be worth chopping the block example up and putting an image of each part of it directly into the doc comment (this is fairly simple to automate with VHS, but requires a lot of effort to do at scale).

@DreadedHippy
Copy link
Contributor

Hi,

I'm interested in fixing this issue. I'd like to start with "Paragraph" but I'm not very sure what needs changing. Could you provide more detail please?

It is unchecked in the list above but it doesn't seem to be missing documentation

@Valentin271
Copy link
Member Author

Hello, it seems the Paragraph has been documented a little bit more since I wrote the list. Still it is missing one docstring for the alignment method. (You can add #![warn(missing_docs)] at the top of the file to see it).

The main type doc can also be improved by referencing to the different concepts of Paragraph.

You can also look here for some guidelines.

@DreadedHippy
Copy link
Contributor

Alright, thank you very much for this.

I'll begin documenting Paragraph and move from there

@joshka
Copy link
Member

joshka commented Sep 4, 2023

@DreadedHippy
Copy link
Contributor

Alright, I will do this

@joshka
Copy link
Member

joshka commented Sep 4, 2023

Also no need to close #467 - this is fine to add as is with the suggested changes.

@DreadedHippy
Copy link
Contributor

DreadedHippy commented Sep 5, 2023

Some guidelines to consider:

How about writing a concise checklist based on the above links (customized for Ratatui) that helps evaluate whether the docs are complete?

  • Are all methods documented?
  • Are all enums documented?
  • Are all documented types hyperlinked?
  • Are the examples given the minimum viable examples?

Do you mean something like the above?
@joshka

@joshka
Copy link
Member

joshka commented Sep 6, 2023

Do you mean something like the above? @joshka
Yep

  • All types, traits, methods, and enums are documented (add #![warn(missing_docs)] once a module is complete)
  • All mentions of a type or function are hyperlinked like [`Layout`]
    To make it easier to read the docs in the doc comment, use references at the end of the comment: [`Layout`]: crate::layout::Layout
  • Interactions between methods are documented at the type level
  • Methods include Panic / Error details
  • Every public module, trait, type, and function has a simple example. The intent of the example is to show why someone would want to use the item, not just how to use it.
  • Examples follow conventions:
    • use a ```plain code fence to show rendered widgets (unless obvious)
    • hide imports in method examples (except: types not part of the prelude / not obvious from context)
    • use use ratatui::prelude::* to avoid common imports
    • use Style::new().red() rather than Style::default().fg(Color::Red)
    • use ? rather than unwrap

@TieWay59

This comment was marked as off-topic.

@Valentin271
Copy link
Member Author

nvim with rust-analyzer does it automatically for me. For vscode there is a rewrap extension. There are probably similar extension for other editors.

@joshka joshka changed the title docs: improve general methods documentation Docs: improve general methods documentation Sep 28, 2023
@farmeroy
Copy link

Is the list of widgets that still need documentation up to date? I was working with various List widgets and Table and would be happy to try to improve those docs

@joshka
Copy link
Member

joshka commented Oct 19, 2023

Is the list of widgets that still need documentation up to date? I was working with various List widgets and Table and would be happy to try to improve those docs

I wouldn't count on it being so - the latest alpha release docs are available at https://docs.rs/ratatui/0.23.1-alpha.6/ratatui/index.html - feel fee to jump in wherever things are missing or could be better explained.

@Valentin271
Copy link
Member Author

I've just checked and it is indeed up to date, those widgets are still missing documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants