You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Simply moving that init doc to a class level improves the situation - documentation is available when importing the class and when initializing the object:
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:
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:
Move all the documentation of an init method as a class docstring
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
The text was updated successfully, but these errors were encountered:
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
:and how it looks like when
ModelTrainer
is imported (there is no documentation for the init method when hovering over the class name)Simply moving that init doc to a class level improves the situation - documentation is available when importing the class and when initializing the object:
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: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:
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
The text was updated successfully, but these errors were encountered: