-
Notifications
You must be signed in to change notification settings - Fork 604
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-documenter] Hyperlinking support for "complex" types (YAML generator) #867
Comments
@AlexJerabek IIRC this syntax will not work today, because the YAML schema does not support it:
Our feature request was for the docs team to improve the schema to allow arbitrary hyperlinks in that field, like this:
Last I checked, this was not supported, in which case support by api-documenter is blocked until that's resolved. (Let me know if that's not the case.) @dend FYI |
@pgonzal I received some updates for APEX on the subject. I'll copy their answers based on the example I provided earlier in the thread here: (Den): For return types, we need to make sure that’s not free form – we should not be putting Markdown there. Instead, we should have a way to separate types properly to make sure that we generate links between angle brackets. Chan – does TypeDoc or JSDoc give us any information on individual types, when complex types are involved for the return field? (Chan): Currently we have parsed this complex return type and resolved the reference of return type but might not work for all possible cases. |
@AlexJerabek let's take this discussion offline. I don't believe today's YAML file has the capability to model what he's describing. |
Is there any update to this issue? The current experience is broken and it is impossible to find the Event API interface needed to carry out the calls for JavaScript developers. People can stumble their way through on TypeScript based on d.ts; but JavaScript only developers are blocked from getting required level of navigation across various types. Could this please be prioritized? |
Someone from the community started PR #1005 which would provide the linking information on API Extractor's side. However if the DocFX the YAML file format cannot represent these links, that would need to be fixed by the DocFX owners as a prerequisite. I seem to remember them saying that they had added a way to do this -- I'll dig through my old email and see if I can find it. @sumurthy since I no longer have direct access to DocFX, one thing that would help a lot is if the GitHub issues included example YAML snippets showing the expected output (which have been tested and confirmed to work). If Office could provide that, it would help get these issues fixed faster. FYI these requests are also basically blocked because it's unclear what the YAML should look like: |
@octogonz FYI, I've reached out on a couple internal docs.microsoft.com channels to get the schema you need. |
@AlexJerabek By the way AE 7.0.41 is a release candidate that hopefully will finally get shipped in the next few days. If you have time, now's a good point to try it out and let us know if you encounter any issues. |
@octogonz Just ran it an received some errors: api-extractor 7.0.41 - https://api-extractor.com/ Using configuration from C:\GitHub\office-js-docs-reference\generate-docs\api-extractor-inputs-office\api-extractor.json
Here's our api-extractor.json file. Is there documentation on how to update it?
|
Yes, the config file schema has changed. Although some field names have changed, and the file paths are resolved slightly differently, the overall semantics are pretty much the same as before. If you run The new
|
@AlexJerabek Here's a rough sketch of what your upgraded file should look like (didn't have time to test it): {
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "office.d.ts",
"apiReviewFile": {
"enabled": false
},
"docModel": {
"enabled": true,
"apiJsonFilePath": "../json/<unscopedPackageName>.api.json"
},
"dtsRollup": {
"enabled": false
},
"messages": {
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
}
},
}
} The |
Thanks @octogonz. The updated json file worked (with the minor tweak of switching I reran our doc generation tooling chain with API Extractor 7.0.41. There do not appear to be any regressions. Hopefully, we can get the OPS yaml schema soon, so this issue can be fixed :-) |
Awesome, thanks! |
@octogonz Here's the response I got from Docs Support:
Not sure if that .cs file unblocks you in any way. |
@octogonz, However, it appears links within unioned types are still not supported, That said, I think it would be beneficial to go forward as if it all works as intended and use UIDs in all the "type" yml sections. Those links will aid significant portions of our documentation. Unlinked UIDs don't look terrible and will eventually be supported. Thoughts? |
It looks like what is needed is for the YamlDocumenter to generate synthetic references using the following policies:
I've tested and verified that this works for UniversalReference documents. Basically what is needed is that when a complex type (such as a generic type, function type, union type, etc.) is to be written to the YAML output it should be converted into a Spec UID. If the Spec UID is not a normal UID reference, then a synthetic reference should be added to the document that maps the Spec UID to the individual UIDs. For example, given the following TypeScript in package import { MyClass } from "foo";
import { A, B } from "bar";
export declare function f(): MyClass<A, B>; We would generate the YAML below: ### YamlMime:UniversalReference
items:
...
- uid: baz.f
name: f()
fullName: f()
langs:
- typeScript
type: function
syntax:
content: 'export declare function f(): MyClass<A, B>;'
return:
type:
- foo.MyClass{bar.A,bar.B}
references:
- uid: foo.MyClass{bar.A,bar.B}
name.typeScript: MyClass<A, B>
fullName.typeScript: MyClass<A, B>
spec.typeScript:
- uid: foo.MyClass
name: MyClass
fullName: MyClass
- name: <
fullName: <
- uid: bar.A
name: A
fullName: A
- name: ', '
fullName: ', '
- uid: bar.B
name: B
fullName: B
- name: '>'
fullName: '>' In essence, the synthetic reference for the type aligns with the excerpt tokens that make up the type. This results in docfx generating the following output as part of its viewmodel: <xref uid="foo.MyClass" displayProperty="name" altProperty="fullName" /><↵
<xref uid="bar.A" displayProperty="name" altProperty="fullName" />, ↵
<xref uid="bar.B" displayProperty="name" altProperty="fullName" />> (note: line continuation arrows (↵) added for clarity) I tested this out on a project of mine. You can see an example of how I'm generating the names here: https://github.com/esfx/esfx/blob/master/scripts/docs/yamlDocumenter.js#L650. You can see the outcome of this here: https://esfx.js.org/esfx/api/collections-linkedlist/linkedlist.html#collections_linkedlist_LinkedList_deleteNode |
Note, this also required making changes to |
@rbuckton, |
@AlexJerabek the current progress is in PR #1337. I will review it this weekend. BTW we've also had a bunch of conversations over the past few weeks about the issues called out in #1308. Ron is proposing some significant improvements to the TSDoc ref notation (and corresponding DocFX UID representations). |
Status update:
|
PR #1337 fixed this issue, so I'll close it. Thank you for everything that went into the fix. |
Currently, the tool uses the uid of a type to help create link to the type's page when API Documenter's yml is run through the OPS build system (for docs.microsoft.com). This works for simple types (like excel.Excel.NamedItemCollection is this example):
However, if the type is in a generic or unioned with another type, the uid is not inserted (like Excel.WorksheetCalculatedEventArgs in this example):
We want Excel.WorksheetCalculatedEventArgs to link to it's page, despite being syntactically part of Office.Extension.EventHandlers.
The text was updated successfully, but these errors were encountered: