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-extractor] Functions and Methods doesn't get their params #292
Comments
This is a bug. Do you want me to create a PR to fix it? Or do you want to create the PR?
Is your implementation open source? Our internal documentation pipeline is unfortunately very complicated (due to requirements of the docs.microsoft.com system), so it would be really useful to have a "reference implementation" that transforms the API Extractor JSON into simple HTML or Markdown pages. If you are coding something like this, it would be awesome if we could include it as part of the the api-extractor package. I started writing something like this a couple weeks ago, and it revealed a bunch of little bugs and oversights in the JSON file that we had overlooked because our production pipeline has so many steps. |
If you can, it would be better you make the changes. I am not really that familiar with this code our how exactly is done. Here are current changes I made to ApiJsonGenerator.
Yes, it's in Looked at |
You will have a much easier time if you go JSON --> markdown instead of ApiItem tree --> markdown. Here is a prototype branch that I was working on, which goes from JSON --> YAML (with each YAML file roughly corresponding to a page on an API documentation web site). The main loop is in ApiYamlWriter.ts. Because JSON is so easy to consume, the whole thing is only a couple hundred lines of code. If you have a general spec for what you want your files to look like, this prototype would be pretty easy to repurpose to produce Markdown instead of YAML, particularly if we could use a proper library (markdown-creator?) instead of string manipulations to create the output. (Markdown has a very complex grammar, so we found that it's difficult to emit strings that don't accidentally get interpreted as formatting styles. Is that asterisk an asterisk, or is it part of a boldfaced region? Ooops, why did those spaces get interpreted as a callout block?) My aim here would be to maintain a concise code sample that people can hack up and customize for their own documentation needs. (This is probably easier than providing a fancy templating system, which will never be customizable enough.) It would also give me a cheap way to validate new documentation scenarios, without waiting for our own big pipeline to support them. Lemme know if you'd want to collaborate on something like that. |
That's true. But in some cases I found that current JSON has not sufficient data to generate something like this: Example Markdown SetBarSummary of SetBar method. public SetBar(bar: Bar): void; Parameters
Returns
Without modifying SetBar(bar: Bar): void Access modifier (public, private, protected) is missing from current version of API JSON. Quick fix was, adding an additional property // visitApiMethod method
// ...
declarationLine: apiFunction.getDeclarationLine(), public SetBar(bar: Bar): void; There are more places that would benefit from this property, like
Yeah, sure. |
Could you open a separate GitHub issue to track this (and any other limitations you encounter)? We are actively working on the documentation pipeline, including JSON schema improvements, and will prioritize this sort of issue. You can also feel free to create a pull request to fix any missing data issues in the JSON -- these are relatively easy fixes. :-)
Okay, maybe I can start by creating a small PR to add the basic skeleton of the Markdown generator, and then you could base your implementation on that, and give us suggestions? I don't really care what your Markdown output looks like, since we will treat it merely as a code sample (that we maintain and use for testing).
I'm fine with that. FYI looking at the implementation, it is missing an escaping mechanism. For example, if you do this: markdown.italic(' Here is my text'); Then you will get this (because of the space before H):
Or this: markdown.italic('Avoid using an asterisk("*")'); Will print this (because the star is not escaped):
This issue will probably be negligible for casual usage, but if you get serious about your documentation, you would want Does that sound like a plan? |
Alright.
I will do a little research, what are other alternatives for markdown generation. We will see about that.
Sounds like a plan 😄 |
FYI I started work on this. Here's my PR branch if you want to follow along: PR 322 Initial prototype of api-documenter tool I'll update this issue when I've merged the first prototype. |
Hi @MartynasZilinskas - following up on this. The initial implementation is fairly close to being finished. I completed the main loop, and now just need to fill out all the different types of data. You can see an example of the current output on this web site: https://microsoft.github.io/web-build-tools/api/ Let me know if you have any feedback about the layout. |
This should be fixed now. |
I started writing my own docs generating implementation and encountered some issues with
api-extractor
module.Functions doesn't get its parameters because object is undefined. Source code: here and here
Example:
JSON output:
I fixed quickly with this:
The text was updated successfully, but these errors were encountered: