Skip to content

Making use of Sphinx autodoc for API docs #454

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

Closed
gtaylor opened this issue Jan 10, 2015 · 5 comments
Closed

Making use of Sphinx autodoc for API docs #454

gtaylor opened this issue Jan 10, 2015 · 5 comments

Comments

@gtaylor
Copy link
Contributor

gtaylor commented Jan 10, 2015

I was trolling through the docs on RTD and noticed that the Client API section is currently being done manually. Since I am a glutton for punishment, I figured I'd see if you would be interested in a pull request that converts this to use Sphinx's autodoc. This would involve moving a lot of what is in that api.md to the source itself.

The benefit of this is that you end up with detailed documentation within the source itself, and it becomes very easy to update docstrings as code is touched.

Just in case an example is needed, we'll continue using boto+dynamodb as an example.

I'd suggest starting with this, then working on a more conversational How-To page that shows some usage examples. I can't promise anything, but I'd potentially be interested in helping as I learn docker-py (and Docker) better.

If you were interested in the autodoc'd API page, that's probably something I could volunteer a pull request for.

@gtaylor gtaylor changed the title Making use of Sphinx autodoc Making use of Sphinx autodoc for API docs Jan 10, 2015
@shin-
Copy link
Contributor

shin- commented Jan 10, 2015

Hi there,

Thanks for chipping in and sharing your thoughts. I admit to being kind of torn on the issue of in-code documentation. It does have some nice upsides as you describe, but my main issue with it is adding bloat to files that should aspire to be as concise as possible (I know client.py fails big time there, and it's something I hope to be able to fix at some point). But in my opinion this makes reading and maintaning the actual code more tedious than it should be.

But I would love to hear other people's opinions on this, as like I said, I can see both sides of the argument here.

@nir0s
Copy link
Contributor

nir0s commented Feb 12, 2015

I've been using Sphinx for a long while now and it's great. I think docstrings make everything more easily understandable. You don't have to skip to the md files everytime you wanna understand what's going on within the code. Sphinx does require that you write RST (other than for the auto-generated API pages) unless you're willing to work with pandoc (I do).

Bottom line is, I'd definitely move from mkdocs to sphinx.

@gtaylor
Copy link
Contributor Author

gtaylor commented Feb 12, 2015

I don't care as much to argue about which documentation system to use (though I do subjectively prefer Sphinx), but almost any modern editor is able to collapse (or auto-collapse) docstrings. As a consequence, I tend to see the "bloat" counter-argument as a weak one.

As @nir0s says, you do get some maintainability benefits, and you also pick up on nice features like being able to cross-reference other modules/classes/functions in the docs (:py:class:somemodule.Class``). You can still do conversational/tutorial style docs to complement your API reference pages, too.

@rutsky
Copy link
Contributor

rutsky commented Sep 17, 2015

  1. Currently API documented in Markdown looks visually awful: there is no distinction between argument names, types, they all just plain text, e.g.:

    Params:

    • path (str): Path to the directory containing the Dockerfile
    • tag (str): A tag to add to the final image
    • quiet (bool): Whether to return the status

    They can be manually formatted, but it's painful and not obvious with limited abilities of Markdown, e.g.:

    Params:

    • path (str): Path to the directory containing the Dockerfile
    • tag (str): A tag to add to the final image
    • quiet (bool): Whether to return the status

    Sphinx provides good formatting out of the box --- just see example, provided by @gtaylor.

  2. IMO, having documentation close to source code is much better that having it in separate place.
    It's easier see what function does in IDE, it's easier to sync function behaviour changes with documentation.

@bfirsh
Copy link
Contributor

bfirsh commented Nov 28, 2016

Fixed in #1186!

@bfirsh bfirsh closed this as completed Nov 28, 2016
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

5 participants