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.

Consistent functions and method docstring style

See original GitHub issue

HoloViews is built on param which has the great advantage of providing a neat way of documenting the parameters of classes. While this is a great way to structure class level parameters, it does not provide anything that documents methods and functions. The current state of the docstrings on methods and functions in HoloViews is therefore what I’d call highly inconsistent and therefore quite frustrating for users.

While a large paragraph explaining what the method does is often sensible, docstrings are far more commonly used to quickly figure out what that one particular argument was called, what options it supports and what type it expects. I therefore think there is a pretty desperate need for us to standardize on some standard docstring format at least for functions and methods.

I’d be strongly in favor of moving to simple NumPy-style docstrings with sections for Parameters and Return values:

Some description of the function or method.

Parameters
----------
x : type
    Description of parameter `x`.
y
    Description of parameter `y` (with type not specified)

Returns
-------
err_code : int
    Non-zero value indicates error code, or zero on success.
err_msg : str or None
    Human readable error message, or None on success.

Readability of this is infinitely better than having to scan a large paragraph for the argument that I care about. After 1.10 is released I’d like to start a systematic review of all docstrings (many of which are hopelessly outdated) and upgrade them to a consistent style. I have no strong preference for any specific format but think that explicitly listing the arguments and return values will result in a much improved user experience and help us consider and address current API inconsistencies.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:36 (35 by maintainers)

github_iconTop GitHub Comments

3reactions
philippjfrcommented, Feb 13, 2018

This is more important for user code than developer code.

Yes, I’d suggest we do it incrementally starting with some of the core classes like Dimensioned, LabelledData, NdMapping, HoloMap, DynamicMap, Element and Dataset.

0reactions
philippjfrcommented, Sep 23, 2019

Since we’ve not made a decision and started the conversion I don’t think we need this issue anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Style guide — numpydoc v1.6.0rc1.dev0 Manual
A documentation string (docstring) is a string that describes a module, function, class, or method definition. The docstring is a special attribute of...
Read more >
PEP 257 – Docstring Conventions
A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition.
Read more >
How to Write Proper Docstrings for a Python Function
There are different styles to create a function's docstrings. The key is sticking to a specific style consistently. For example, if you work ......
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
Python documentation string or commonly known as docstring, is a string literal, and it is used in the class, module, function, or method...
Read more >
What are the most common Python docstring formats? [closed]
I tend to always include docstrings, because they tend to demonstrate how to use the function and what it does very quickly. I...
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