question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enhance docstring with code examples

See original GitHub issue

most pytorch modules come with nice examples in the docstring. for example, the docstring of torch.nn.modules.Conv1d has this block:

    Examples::
        >>> m = nn.Conv1d(16, 33, 3, stride=2)
        >>> input = torch.randn(20, 16, 50)
        >>> output = m(input)
    .. _cross-correlation:
        https://en.wikipedia.org/wiki/Cross-correlation
    .. _link:
        https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md

these are also available in the autogenerated documentation site: Screenshot 2020-05-30 at 17 43 04

MONAI’s modules should also include such intuitive examples.

(currently It’s been done for only a few classes, e.g.: https://github.com/Project-MONAI/MONAI/blob/master/monai/transforms/croppad/array.py#L164-L176)

Describe the solution you’d like I understand it’ll be difficult to enforce this feature for all modules. but once it’s there it’ll greatly improve usability. this feature request will probably require multiple PRs.

as a starting point, we could extract some examples from the existing unit tests.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hjmjohnsoncommented, Jun 6, 2020

@wyli I was planning to have my team work on some of this as we work through using MONAI on our projects. It is a next item after type hinting is in better shape.

1reaction
wylicommented, Jun 1, 2020

Hi @wyli, I would like to work on this. is it open for anyone to contribute?

yes, it is, please feel free to create PRs (there’s a contributing.md in case you haven’t read it)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Python Docstrings for Effective Code Documentation
Documenting your code is a critical skill for any data scientist or software engineer. This tutorial will show you how using docstrings.
Read more >
Documenting Python Code: A Complete Guide
A complete guide to documenting Python code. Whether you're documenting a small script or a large project, whether you're a beginner or seasoned...
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
Docstrings are similar in spirit to commenting, but they are enhanced, more logical, and useful versions of commenting. Docstrings act as documentation for...
Read more >
Python Docstrings (With Examples) - Programiz
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module. Let's take an example....
Read more >
Example Google Style Python Docstrings - Napoleon
coding: utf-8 -*- """Example Google style docstrings. This module demonstrates documentation as specified by the `Google Python Style Guide`_.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found