-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Document the API #1339
Comments
I disagree, documenting everything would be extremely difficult. In the end, the only real source of truth is the code itself. One of the reasons we're all writing python not c is that it's easily readable. I'd be happy to accept a PR to add info on |
I'm not asking about documenting absolutely everything :) but The API documentation is usually auto-generated (meaning no inconsistency possible between the code and the doc) and makes it possible for advanced users to go straight to the answers, whereas guides provide a more narrated way of discovering the library. Here are some good examples of API reference from some major packages:
Here are some good arguments in favor of having an API reference:
|
See this fairly long discussion on the matter. I'm strongly opposed to multiple different types of documentation, I think there should be one and only one section of documentation on a feature. That's impossible to achieve entirely, but adding a whole new "api" section to the docs makes it impossible.
Is that really true? It's not for python itself, or aiohttp, I wonder if it is for many of the projects you list above. As mentioned on the issue above, it generally doesn't work that well. There's also no widely used way to auto-generate docs in markdown - maybe that's a strong hint that it's not a populate approach anymore. Even if they were, the value in docs is in the examples and descriptions. That still has to be written even if it's in docstrings, not md files. More generally I know the docs could be better, however I don't much enjoy writing docs myself and I get very little help on it from others. I maintain pydantic for fun and I don't want to spend a significant amount of my free time writing docs, apparently neither does anyone else. I setup patreon to see if people would who use pydantic would contribute financially, and thereby pay me to do the boring donkey work like docs. It pays me $13/mo. I charge £100/hr for development, so that would pay me for 6'30" a month to improve the docs (at the current exchange rate). There's also the problem of upkeep once the docs are written. I find it hard enough to get people to document the features they add or modify in pull requests. That would only get harder if they had to extend the API docs as well as modify the main documentation. In short, I think best to submit a PR to add docs for specific things instead of adding another massive section to the docs. |
Hey Samuel, thanks for taking the time to answer. I understand your position. I would still submit that it goes against what most packages are doing, but that would be a somewhat fallacious argument from authority. I think there are two discussions. Whether or not I strongly think it should be the case. You don't. In the end, if I don't manage to convince you that it's a useful thing, there's no point in moving further on this ticket and you can close it because you're the repo owner. Re. your arguments:
If you agree there should an API reference, how to build it I'd be happy to help! But it's true that the API absolutely needs to be generated, otherwise, it will be a nightmare to maintain them. Another way would be to just include the main parts of the code in the docs (e.g. the Anyway, in conclusion, just wanted to say that an open source contributor and maintainer myself, I empathize with your feelings re. the time it represents. |
Thanks for your input, I get where you're coming from. Let's see what others think, if lots of people support this I'll think about it more. Requirements:
There's currently no way to render rst documents within mkdocs, see mkdocs/mkdocs#1817. So the options are:
If we do have to do this, my preference would be option 4, but even this is a big piece of work that would require a library of its own and ~10 hours of work before we could start using it. |
Re: Autogenerating documentation from markdown docstrings, https://github.com/pawamoy/mkdocstrings has sprung up as a mkdocs plugin/extension to do just that, and @pawamoy is currently working on implementing a filter option for more detailed control. It currently:
I can try putting together a PR for documenting things, if you or @charlax have a suggestion of classes to doc, |
Funny, seeing pydantic and fastapi docs is what made me want to use mkdocs, and then build mkdocstrings 😄
UPDATE: mkdocstrings now has a |
I would love to see |
O_o |
I tend to use sphinx for my doc. Mostly prose, but I like generated api doc to exist so I can hyperlink to it. That being said, there is no I think that providing objects.inv would be very nice! |
FYI there's MyST for Sphinx+Markdown+RST directives now: https://myst-parser.readthedocs.io/. |
API docs. Gotta have. |
Great resource on the topic: https://documentation.divio.com/reference/ |
I'm not sure what's expected here. If the goal is to have more information on |
I would also love to have API documentation with |
I have plans for this. It it won't be using sphinx, but rather mkdocstrings which I've used very successfully recently in dirty-equals and watchfiles. |
+1 for this! A cross-linked API reference page is extremely valuable in nearly every library/framework that I've used. I assume that @Czaki was specifically talking about setting this up to be compatible with Intersphinx which automagically creates links to external docs for directives like so: :func:`This is a link to the Numpy docs! <numpy.asarray>` I unfortunately don't know what's required to make that work (perhaps you just need URLs like |
Mkdocstrings can do the same thing I think. |
Indeed, it's documented here: https://mkdocstrings.github.io/usage/#cross-references-to-other-projects-inventories :) |
But this is the documentation on how to add references. Did mkdocs generate |
Interesting question, @pawamoy would there be a way for others to reference pydantics docs from their docs? |
That's probably not very clear in the docs, but yes:
It means |
I second the need for API reference. This is important. It does not mean that every feature needs very detailed docs. At the same time, one of the first things I see is the Field object and no documentation whatsoever on it. This is not right. |
It does: https://pydantic-docs.helpmanual.io/usage/schema/#field-customization API documentation will be done in V2, this is already stated in the blog about V2. |
Thanks! |
fixed in #5565, still some work to do, but we're on it. |
Feature Request
It would be great to include API documentation. The Usage docs are great as a walkthrough, but when you want to go fast ("what is the name for the
Field
parameter for a constant value?"), API docs provide a faster answer.Another use case: I want to inspect the
__fields__
on a model, and had to read the code to get the attribute name I was looking for.API docs would be such a great addition to this amazing library! Super useful!
The text was updated successfully, but these errors were encountered: