docs: improve docstrings for API reference (#612)#614
docs: improve docstrings for API reference (#612)#614planetf1 wants to merge 7 commits intogenerative-computing:mainfrom
Conversation
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
jakelorocco
left a comment
There was a problem hiding this comment.
I think this seems reasonable. I tried to look at very important parts of the code base (ie core) and the changes seemed reasonable.
We should remove the attributes from the docstring and move any attribute descriptions we want to be docstrings on those fields. At least for me, having both attributes and args causes confusing output in VSCode: 
Docstrings directly on the fields also allows for detailed descriptions when hovering them.
def __init__(f1: int):
self.f1 = f1
"""field 1"""
…mputing#612) Replace one-liner and missing module docstrings across 53 files with substantive 2-4 sentence descriptions covering each module's purpose, key exports, and when to reach for it. Covers all three priority tiers from the issue: __init__.py landing pages, undocumented modules, and short stubs that merely restated the module name.
…omputing#613) Add missing ``Args:`` and ``Returns:`` sections to all public functions and methods across ``mellea/`` and ``cli/`` that lacked them. Also converts RST-style ``:param:``/``:returns:`` docstrings inherited from the ``granite_io`` upstream into Google style to match the project convention (``pyproject.toml`` ``convention = "google"``). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…computing#613) Add or expand Google-style docstrings across CLI and library modules: - cli/alora/train.py: add docstrings to load_dataset_from_json, formatting_prompts_func, SaveBestModelCallback, SafeSaveTrainer, train_model - cli/decompose/decompose.py: add class docstring to DecompVersion, expand run() with full Args section - cli/decompose/pipeline.py: add class docstrings to ConstraintResult, DecompSubtasksResult, DecompPipelineResult, DecompBackend; add full docstring with Args/Returns to decompose() - cli/decompose/utils.py: add Args/Returns to validate_filename - cli/eval/commands.py: add full docstring with Args to eval_run - cli/m.py: expand callback docstring - mellea/backends/adapters/adapter.py: expand LocalHFAdapter docstring - mellea/backends/cache.py: expand SimpleLRUCache docstring - mellea/backends/tools.py: expand SubscriptableBaseModel docstring; fix json_extraction to use Returns: instead of Yields: - mellea/core/backend.py: expand Backend docstring; add Args/Returns to generate_walk - mellea/core/base.py: add Args/Returns to blockify and get_images_from_component - mellea/core/utils.py: expand RESTHandler, JsonFormatter, FancyLogger class docstrings - mellea/helpers/openai_compatible_helpers.py: add Args/Returns to message_to_openai_message and messages_to_docs - mellea/stdlib/components/docs/richdocument.py: expand TableQuery and TableTransform class docstrings - mellea/stdlib/components/genslot.py: expand Argument, Function, Arguments, GenerativeSlot class docstrings; add SyncGenerativeSlot class docstring - mellea/stdlib/components/mobject.py: expand Query and Transform class docstrings - mellea/stdlib/requirements/requirement.py: add Args sections to req() and check() - mellea/stdlib/sampling/budget_forcing.py: expand BudgetForcingSamplingStrategy class docstring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e-computing#613) Add Args: sections to class docstrings that had Attributes: but no Args:, completing Google-style docstring coverage: - core/requirement.py: ValidationResult, Requirement - core/sampling.py: SamplingResult - core/base.py: CBlock, ImageBlock, ModelOutputThunk, ContextTurn, TemplateRepresentation, GenerateLog, ModelToolCall - formatters/template_formatter.py: TemplateFormatter - formatters/granite/intrinsics/input.py: IntrinsicsRewriter - formatters/granite/intrinsics/output.py: TransformationRule, TokenToFloat, DecodeSentences, MergeSpans - formatters/granite/retrievers/embeddings.py: InMemoryRetriever - stdlib/components/chat.py: Message, ToolMessage - helpers/async_helpers.py: ClientCache
|
Thanks for the feedback @jakelorocco — glad the core changes look ok! Agree — I see this with Pylance too. The hover output is confusing. I looked at a few instances:
So I've dropped the redundant Happy to raise a follow-on issue if there are more cases elsewhere. |
…ve-computing#613) Remove Attributes: sections where fields duplicate constructor params verbatim (same name, same type, same description), keeping only entries that add genuinely new information (computed/derived attributes): - mellea/backends/backend.py: FormatterBackend - mellea/core/base.py: CBlock, ImageBlock, ModelOutputThunk, ContextTurn - cli/eval/runner.py: InputEvalResult, TestEvalResult (keep computed properties passed_count, total_count, pass_rate) Also removes TASK.md left over from development. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
b05ea2c to
0a0bcc7
Compare
|
Changes made, but check failing with some type checking errors from cpex: Will look at how to address... maybe bad in main? |
mypy 1.18.2 reports import-not-found for cpex.framework.* (which has no py.typed marker). 1.19.1 handles this correctly and was the version used when PR generative-computing#582 passed CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Build failure caused by regressed uv.lock from resolving merge conflict. Updated/pushed |
@planetf1, looking at the style guide, it looks like Attributes and Args serve different purposes. Attributes are in class docstrings while Args are in function docstrings. I think this line is somewhat blurred because (VSCode at least) rarely shows the class docstring. I think we should:
if we want to maintain attributes in the docstring. |
|
will revisit content/attribute discussion once pipeline pr progressed - there is some relationship in parsing/validation. |
Misc PR
Type of PR
Description
Fixes #612, Fixes #613
Comprehensive docstring quality pass across the entire
melleaandclicodebase, covering four areas. Note that during implementation additional gaps were identified beyond those listed in the original issues and fixed in the same pass.This PR is independent of #611 (the API doc pipeline tooling) and can be merged without it.
Module-level docstrings (#612)
Expands module-level docstrings across 53 files covering all three priority tiers from the issue:
__init__.pylanding pages (P1), modules with no docstring at all (P2), and one-liner stubs that merely restated the module name (P3). Each docstring now describes the module's purpose, its key exports, and when to reach for it.Google-style Args/Returns/Raises (#613)
Adds missing
Args:,Returns:, andRaises:sections to public functions and methods across all modules. Also converts RST-style:param:/:returns:docstrings (inherited from upstreamgranite_io) to Google style to match the project convention (pyproject.tomlconvention = "google").Attributes: sections on class docstrings (#613)
Adds or expands
Attributes:sections on class docstrings acrosscore,backends,formatters,stdlib, andcli, covering classes such asRESTHandler,JsonFormatter,FancyLogger,SimpleLRUCache,SubscriptableBaseModel,TableQuery,TableTransform,GenerativeSlot,Query,Transform,BudgetForcingSamplingStrategy, and others.Class-level Args: sections (#613)
Adds
Args:sections to class docstrings that hadAttributes:but noArgs:, covering 19 classes — including dataclasses whose__init__is auto-generated from field annotations. Several of these were identified during review rather than appearing in the original issue report.Testing