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

Improve docstrings #107

Closed
kjordahl opened this issue Jul 11, 2014 · 5 comments
Closed

Improve docstrings #107

kjordahl opened this issue Jul 11, 2014 · 5 comments

Comments

@kjordahl
Copy link
Member

Some docstrings are missing, some are fairly rudimentary. All modules, classes, methods and functions should have useful docstrings.

@souravsingh
Copy link

I would like to work on this issue.How Do I work on it?

@jorisvandenbossche
Copy link
Member

@souravsingh For how docstring should look like, you can look at existing docstring, and also take a look at the specification of the Numpy docstring standard: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt for an explanation of the syntax and the different sections.

Then I would say, go through the different methods/classes of geopandas and see if there are ones were a full docstring is lacking, and try to add an explanation of the parameters, add an example, ..

@kjordahl
Copy link
Member Author

kjordahl commented Nov 6, 2015

@souravsingh Here's one example: The plot() method of a GeoDataFrame has no docstring at all. It just calls plot_dataframe() function (which has a decent docstring), so it takes the same options. As a consequence, currently a user in IPython can't get useful help from GeoDataFrame.plot?, you can't build complete API documentation, and so on.

There are a few options to fix this example:

  • We could add a short docstring to the plot() method, referring users to plot_dataframe() for the complete options.
  • We could copy the docstring from plot_dataframe(), adjusting as necessary. This has the drawback of adding a maintenance burden of keeping the options up-to-date in two independent places. I would prefer not to do this if possible.
  • We could define the docstring (or a subset) in one place, and alter the __doc__ attribute of the class to add the appropriate common parts. This is probably manageable if they are identical, but a bit trickier if is mix-and-match. I think it can work in this case. In more complicated cases, it could impair the readability of the code.

There are other missing and incomplete docstrings in the code, and the tradeoffs between these options may be slightly different in other cases.

Thanks for helping out!

@jorisvandenbossche
Copy link
Member

@kjordahl even another option is to define GeoDataFrame.plot = plot_dataframe. In this way, the docstring is automatically used (as well as the keyword inspection, instead of the **kwargs now). This is also how pandas does it: https://github.com/pydata/pandas/blob/v0.16.2/pandas/core/frame.py#L5138

@martinfleis
Copy link
Member

Closed by recent documentation enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants