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

"API Specification" Style Documentation #2003

Open
76784 opened this issue Apr 2, 2019 · 14 comments
Open

"API Specification" Style Documentation #2003

76784 opened this issue Apr 2, 2019 · 14 comments

Comments

@76784
Copy link
Contributor

76784 commented Apr 2, 2019

I would love to see API Specification style documentation for Sinon, along the lines of what you see in Java (the gold standard of documentation), or jQuery.

An A-Z alphabetical list of functionality, written in a non-conversational way (which is how the current documentation is currently written) is what this documentation needs.

@76784
Copy link
Contributor Author

76784 commented Apr 3, 2019

By the way, I'm not harping on the current documentation, which is valuable. I'm merely suggesting an additional, comprehensive thing.

@mantoni
Copy link
Member

mantoni commented Apr 3, 2019

Java has automatic tools to generate JavaDocs without manual work. To achieve something like this in a JS library requires a ton of manual work. I'd love to see something like it, but I fear it would outdate pretty quickly.

We could bikeshed about code annotations and tooling a little. Maybe there are viable options.

@76784
Copy link
Contributor Author

76784 commented Apr 4, 2019

I know it's been brought up on other threads, but I think, very simply, that the entire library should be documented with jsDoc. It is something of a defacto standard for JavaScript (or, at least, the strongest argument there is for one). We could just publish the api starting with mimimal documentation coverage, and put a big "in progress" sign on the wall, and build from there.

@fatso83
Copy link
Contributor

fatso83 commented May 31, 2019

@mantoni There are lots of tools for auto-generating JSDocs. I don't see a v1 of this to be an issue. You don't need to create @typedefs everywhere. Just having

/**
  @param {String} [foo] optional string
  @example Create foo instance
       var foo = dooFoo('somestring') 
*/ 

would help quite a bit.

@lucasfcosta
Copy link
Member

Hi @76784, that's great input! 😊

I have, however, a few considerations to make.

I quite like JSDoc. That's also what we use on Chai.js and it's worked pretty well so far due to being able to separate things into namespaces and always keep code in sync with docs since they're right next to each other.

However, I'd disagree that Java's documentation is the "gold standard". I find Java docs to be very dry. It's good for reference, but bad for learning or groking bigger parts of it. I like the fact that docs for Sinon are written in friendly plain-text classical style. IMO that helps driving adoption. Also, as an API reference they're pretty good IMO.

I think would be good, of course, to have JSDocs, but it's important to notice that it would require an extremely significant effort.

@fatso83
Copy link
Contributor

fatso83 commented Jun 4, 2019

If @76784 would start a branch and flesh out some concepts, I think some people attracted to the idea could quickly latch onto it and help out. The API surface isn't that big.

@76784
Copy link
Contributor Author

76784 commented Jun 9, 2019

@lucasfcosta

I find Java docs to be very dry. It's good for reference, but bad for learning or groking bigger parts of it.

I don't disagree. I'm merely saying that the two things - documentation and tutorial - should be separate things. The dryness of javadocs is a plus. One is able to go there and find out, through this dry-language convention, what the "thing" does. And of course, most importantly, it is comprehensive in nature. I don't want wordy sentence structure in my documentation - I want that in my tutorial.

I'm not an expert in JSDoc, but I wonder if in the JSDoc comments there would be an easy way to link to the tutorial for the entry.

As for contributing some proofs-of-concept on this, @fatso83 , I'm a bit short of time at the moment (I know, who isn't?), but I might be in a better position to later in the year. It would be a great way to learn Sinon thoroughly.

@stale
Copy link

stale bot commented Aug 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 8, 2019
@mroderick mroderick added pinned and removed stale labels Aug 9, 2019
@mroderick
Copy link
Member

I’ve pinned this issue, so it doesn’t get closed by Stale bot

@mroderick
Copy link
Member

If we do decide to go down this road, then I think we should use something like https://github.com/gajus/eslint-plugin-jsdoc ... the rules should probably go into eslint-config-sinon.

@76784
Copy link
Contributor Author

76784 commented Aug 17, 2019

Sorry to dive in and out of this - it's really driven by some work priorities. And I don't know if this is the right thread, but just to offer some more feedback on the existing documentation...

As I look at something like spies: https://sinonjs.org/releases/v7.4.1/spies/

I happen to be working with Mocha, which has a different syntax from what is shown in the first chunk.

"test should call subscribers on publish": function () {
    var callback = sinon.spy();
    PubSub.subscribe("message", callback);

    PubSub.publishSync("message");

    assertTrue(callback.called);
}

The fact that I'm using Mocha instead of whatever that is (Jasmine?) is no biggie. They're obviously similar. But what does make that example hard to understand is that you don't show the function that is being tested.

That is something I think should be done if you're going to provide examples. Show the minimum working functionality of whatever thing is being tested. Same issue here, with myLib: https://sinonjs.org/releases/v7.4.1/fake-xhr-and-server/

I get it - myLib is something I would write. But you're asking a lot of the newbie to have to learn this stuff without seeing any of what they're testing against.

@fatso83
Copy link
Contributor

fatso83 commented Aug 18, 2019

Actually that test IS using Mocha's syntax, you're just using the more standard BDD style (of the two) :-) It's also shared by some other libraries, such as Buster JS, which Sinon's original creator also (co-)created. Anyway, it would probably make sense for someone to update all the examples to the most common style in use :-)

As to the other points, these are quite valid, and something we have discussed. Actually, we discussed having runnable, tested, embedded examples, guaranteeing validity. Which implicitly would fix those issues. But yeah, someone needs to sit down and do it ...

@76784
Copy link
Contributor Author

76784 commented Aug 18, 2019

Actually that test IS using Mocha's syntax

What?? Now I'm going to have to go rant about the Mocha documentation. :-)

@mroderick mroderick mentioned this issue Aug 26, 2019
2 tasks
@mroderick
Copy link
Member

I've tried to start this effort in sinonjs/samsam#82. Your comments welcome, please post them on that PR.

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