rust-lang / rust-lang/rfcs

Documentation: function/method parameter lists

Open
#1,929 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-doc
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

I was working to clarify the meaning of some parameters in someone else's project and suddenly realized there was no explicit way to document this aspect of the code.

My stop-gap attempt is to drop a bullet list into the long description, but it might be nice to have special handling around this.

/// Draws the given `Drawable` object to the screen.
///
/// * `ctx` - The `Context` this graphic will be rendered to.
/// * `drawable` - The `Drawable` to render.
/// * `quad` - A portion of the drawable to clip.
/// * `dest` - the position to draw the graphic expressed as a `Point`.
/// * `rotation` - orientation of the graphic in radians.
///
pub fn draw(ctx: &mut Context,
            drawable: &mut Drawable,
            quad: Rect,
            dest: Point,
            rotation: f32)
            -> GameResult<()> {
    drawable.draw(ctx, quad, dest, rotation)
}

In a language like Python, documenting parameters has greater importance since it provides hints to the expected types, but it still offers a good opportunity to discuss usage of, and how incoming values contribute to a result.

class Client(object):

    def __init__(self, url, api, mappers=None, default_chunk_size=200):
        """
        :param str url: full url to the atlas instance.
        :param str api: the api version to use.
        :param dict mappers: mapper classes to use for the element types
                             named in the keys.
        :param int default_chunk_size: sets the cursor limit for times when it
                                       is not being explicitly set by the
                                       caller.
        :raises atlas.exceptions.ServerCompatError: if server url is for an
                                                    incompatible server
                                                    version.
        """
        # ...

While having this info show up in the docs, this could also be leveraged in tooling (IDEs, etc).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the Rust and Python examples in the issue first; no repository files, tests, or entry points are named. Before implementation, define the documentation syntax and tooling behavior, then use that definition to establish what a completed change should demonstrate.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.