Godoc for the API compatible with swagger generators#16125
Conversation
|
Is it worth doing this before the API split is done? I'd prefer to reduce the number of moving parts while we're trying to split things up. /cc @kostickm |
6ddc9c8 to
8de0620
Compare
|
@duglin the thing is that we don't need to change router libraries if we use a static generator like this. I'm open to suggestions, I wanted to open both PRs so we can compare and decide. I think this change is less intrusive. |
8de0620 to
ffb86fd
Compare
|
I really like how Stripe/Paypal present their API docs: https://stripe.com/docs/api https://github.com/tripit/slate provides a responsive template similar to Stripe's docs. It uses markdown for its documentation format. I wonder if this might be useful for the Docker API docs. I put together a Docker theme. I added some of the existing content (markdown) to the template to see how it might look: http://lyndaoleary.github.io/docker-api-docs/#api-reference It would be really cool if we could create something that would automatically generate markdown documentation based upon the Swagger spec 😄 |
|
@lyndaoleary I agree with you. The script in this PR already generates markdown, but I haven't had time to hook slate to it. Ideally, we'll probably want to generate as much static html as possible, and we'll probably have to bring some of the docker branding to the final look and feel. I have more doc comments to add here, but I found a few issues with the generator. |
|
@lyndaoleary PS: that looks very cool. |
1e5352f to
16fef58
Compare
With this approach, we will be able to generate API documentation from go comments. I think I like it better because it's less intrusive than moving to a new router framework. Signed-off-by: David Calavera <david.calavera@gmail.com>
16fef58 to
ea0cb8f
Compare
|
I removed all the generation scripts for now, they are slightly buggy. I think there are advantages to have the documentation in the code even though we don't generate the final output yet. Please, take a look. |
|
@calavera could you help me out a bit here "what" needs to be reviewed, as I'm not sure (forgive my n00bishness); Are the annotations used in this PR and existing standard, or something you invented/created? If they're not an existing standard;
FWIW, I like the use of annotations for these! Looking at these examples;
|
|
Okay, finally some time to address all @thaJeztah's comments 🎉
Indeed, should we explain how to document this handlers, which should include the list of supported annotations. The main concept is from http://beego.me/docs/advantage/docs.md
I think that should be part of what we end up using to generate the final documentation. It could be part of the build if we wanted to do that, but I don't think it should be part of this.
Both are compatible. You can see an example at the beginning of the server file. The first line is GoDoc, the rest is api documentation. I added that because otherwise golint complains because the format of the comment is not correct. As you can see, it doesn't complain now.
That's up to what we use to generate the final doc. From my point of view, I'd expect it to support several lines.
This is up to consideration. I don't really have a good answer, I guess we could extend the
Agreed.
Yes, this could be as easy as doing something like I hope this answers all you comments. At the end of the day, I think most concerning things will rely on whatever we use to generate the final doc. I think, even if we never arrive to generate a final doc, this is very useful as a general purpose documentation in the code. |
Yes, it does, thanks! And, I agree that these annotations can be very useful; they give more structure to the way these endpoints are documented; would be interesting to see if we can use this to generate the stripe-docs that @lyndaoleary showed (#16125 (comment)) as well. I'd be interested in @stevvooe's opinion/thoughts here; I know https://github.com/docker/distribution also generates documentation for the specs (don't know who actually wrote the code to generate that tbh) |
We can use this to generate markdown files. Slate uses plain markdown to render those pretty docs. |

With this approach, we will be able to generate API documentation from go comments.
I think I like it better because it's less intrusive than moving to a
new router framework.
/cc @icecrime
Signed-off-by: David Calavera david.calavera@gmail.com