Code Monkey home page Code Monkey logo

Comments (12)

tkf avatar tkf commented on July 1, 2024

Other popular docstring syntax to document function parameter is numpydocs https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt#id6

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

I've had this idea once before, but at the moment I don't have the time to add this, could be a good addition.

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

Are there any other (popular) ways to declare types for python params?

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

I found something: http://www.python.org/dev/peps/pep-0257/ (but I really would like to know about other types).

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

There are also "googley" docstrings:

"""This function does something.

    Args:
       name (str):  The name to use.

    Kwargs:
       state (bool): Current state to be in.

    Returns:
       int.  The return code::

          0 -- Success!
          1 -- No good.
          2 -- Try again.

    Raises:
       AttributeError, KeyError
"""

from jedi.

tkf avatar tkf commented on July 1, 2024

No, I don't know other styles (including that google style!). I think Sphinx is a good first step, as I assume it is the most famous and used style and you can use docutils instead of writing your own.

from jedi.

tkf avatar tkf commented on July 1, 2024

In matplotlib, ReST table is used for documenting keyword arguments. But I guess supporting this style won't help people other than matplotlib devs.

          ================   =========================================
          Keyword            Description
          ================   =========================================
          *adjustable*       [ 'box' | 'datalim' | 'box-forced']
          *alpha*            float: the alpha transparency (can be None)
          *anchor*           [ 'C', 'SW', 'S', 'SE', 'E', 'NE', 'N',
                               'NW', 'W' ]
          *aspect*           [ 'auto' | 'equal' | aspect_ratio ]
          *autoscale_on*     [ *True* | *False* ] whether or not to
                             autoscale the *viewlim*
          ...

https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py#L392-433

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

I added sphinx docstrings and "googley" docstrings. I ignored the matplotlib ones because they are not typical for Python and also ignored numpy docstrings (for now) because they might be misinterpreted.

from jedi.

tkf avatar tkf commented on July 1, 2024

This is really cool! Thank you very much.

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

It's really only the basics, I have to improve things like list of str...

from jedi.

jkb0o avatar jkb0o commented on July 1, 2024

I didn't found any definition of googley docstrings. The only tink I found is http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments which does not provide any format for param types or return types.

I'd like to remove google docstrings support to keep existing code clean and simple. Unless someone provide docstrings api(format) atleast.

from jedi.

davidhalter avatar davidhalter commented on July 1, 2024

You're probably right. The reason why I included it in the first place was this: http://packages.python.org/an_example_pypi_project/sphinx.html

But that's just an example. No specification. So feel free to remove it.

from jedi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.