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

[Enhancement]: Simple improvements for documentation #3518

Open
fkdosilovic opened this issue Aug 1, 2024 · 0 comments
Open

[Enhancement]: Simple improvements for documentation #3518

fkdosilovic opened this issue Aug 1, 2024 · 0 comments
Labels
feature A new feature

Comments

@fkdosilovic
Copy link

Problem statement

I find my self more often than I would like switching to web API docs for flair for a simple look at specific class's documentation, especially for __init__ arguments. The reason for this is actually simple - the documentation for init method is not on a class level (i.e. class docstring) and is wrongly formatted.

For example, here is the code for ModelTrainer:

class ModelTrainer(Pluggable):
    def __init__(self, model: flair.nn.Model, corpus: Corpus) -> None:
        """Initialize a model trainer.

        Args:
            model: The model that you want to train. The model should inherit from flair.nn.Model  # noqa: E501
            corpus: The dataset used to train the model, should be of type Corpus
        """

and how it looks like when ModelTrainer is imported (there is no documentation for the init method when hovering over the class name)

Screenshot from 2024-08-01 22-28-16

Simply moving that init doc to a class level improves the situation - documentation is available when importing the class and when initializing the object:

Screenshot from 2024-08-01 22-31-54

The second problem is seen on the latest picture - the documentation is wrongly presented. To fix this, so that each argument has its own line, a double space (line break in markdown) should follow after description for each argument.
In the case for ModelTrainer a simple double space after the # noqa: E501 solve the issue:

Screenshot from 2024-08-01 22-40-30

I know that scikit-learn follows this convention (docstring for __init__ is a part of class docstring) and it is super helpful.

Note: This is a problem for VS Code, I do not know how other IDE's/Editors behave with flair's documentation.

Solution

As I mentioned above:

  1. Move all the documentation of an init method as a class docstring
  2. Add double space at the end of each argument

Create a meta issue (we can use this one) that collects and follows in that issue all flair classes that are a part of public interface that require the aforementioned changes. Potential contributors can than submit PR for the new documentation and mention on what module are they working on.

Additional Context

No response

@fkdosilovic fkdosilovic added the feature A new feature label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

1 participant