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

Make "Show Source" useful #3252

Closed
sgdecker opened this issue Oct 30, 2023 · 1 comment · Fixed by #3281
Closed

Make "Show Source" useful #3252

sgdecker opened this issue Oct 30, 2023 · 1 comment · Fixed by #3281
Labels
Area: Docs Affects documentation Type: Enhancement Enhancement to existing functionality

Comments

@sgdecker
Copy link
Contributor

What can be better?

When looking at the documentation for various functions in the MetPy Reference Guide, in the right column there is an icon followed by "Show Source". However, the information revealed by clicking on "Show Source" is not particularly useful.

For instance, for read_colortable, "Show Source" shows:

read_colortable
===========================

.. currentmodule:: metpy.plots

.. autofunction:: read_colortable

.. include:: metpy.plots.read_colortable.examples

.. raw:: html

      <div style='clear:both'></div>

I would find a display of the actual source code that implements the read_colortable function to be more useful in this context, or perhaps the "raw" text of its docstring.

So for this particular function, I think:

def read_colortable(fobj):
    r"""Read colortable information from a file.

    Reads a colortable, which consists of one color per line of the file, where
    a color can be one of: a tuple of 3 floats, a string with a HTML color name,
    or a string with a HTML hex color.

    Parameters
    ----------
    fobj : file-like object
        A file-like object to read the colors from

    Returns
    -------
    List of tuples
        A list of the RGB color values, where each RGB color is a tuple of 3 floats in the
        range of [0, 1].

    """
    ret = []
    try:
        for line in fobj:
            literal = _parse(line)
            if literal:
                ret.append(mcolors.colorConverter.to_rgb(literal))
        return ret
    except (SyntaxError, ValueError) as e:
        raise RuntimeError(f'Malformed colortable (bad line: {line})') from e

or a subset of the above would be better. But maybe I'm completely missing the point behind these "Show Source" links.

@sgdecker sgdecker added the Area: Docs Affects documentation label Oct 30, 2023
@dopplershift dopplershift added the Type: Enhancement Enhancement to existing functionality label Oct 30, 2023
@dcamron
Copy link
Member

dcamron commented Oct 30, 2023

Oops, we were supposed to hide that, but I misspelled the config never did. This button from the theme is only for the doc source. However, I'll go see about enabling the linkcode extension to add a source button a la NumPy, Pandas, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Docs Affects documentation Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants