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

Add support for including canonical URLs for References #115

Open
kevinpschaaf opened this issue Jan 17, 2023 · 0 comments
Open

Add support for including canonical URLs for References #115

kevinpschaaf opened this issue Jan 17, 2023 · 0 comments

Comments

@kevinpschaaf
Copy link
Collaborator

When generating documentation from a manifest that may include references to 3rd-party packages, it may be useful for a 3rd-party package to describe canonical URLs to documentation for specific Reference.

For example, take the following example:

// my-foo.ts
import {FooElement} from 'foo';
export class MyFoo extends FooElement { ... }

Which would create the following CEM snippet:

{
  "modules": [
    {
      "kind": "javascript-module",
      "path": "my-foo.js",
      "declarations": [
        {
          "kind": "class",
          "name": "MyFoo",
          "superclass": { "name": "MyFoo", "package": "foo" },
        }
      ]
    }
  ]
}

An API documentation generator might like to show documentation such as this:

## Classes
### MyFoo
Extends: [`FooElement`](https://foo-library.com/api/FooElement.html) from `foo`
#### Fields
...
#### Methods
...

Where the link on FooElement links to the canonical documentation for FooElement. While an API documentation generator could retrieve the CEM for foo and generate / link to that documentation locally, as an option it would be useful if a CEM could say, "the canonical documentation URL for FooElement is at https://foo-library.com/api/FooElement.html".

Proposed schema addition:

/**
 * A reference to the canonical documentation of a declaration.
 */
export interface DocumentationReference {
  /**
   * An absolute URL to canonical API documentation.
   */
  href: string;
}

and add

  documentation?: DocumentationReference

to all declaration types.

So in the above example, the CEM for foo might look like:

{
  "modules": [
    {
      "kind": "javascript-module",
      "path": "foo-element.js",
      "declarations": [
        {
          "kind": "class",
          "name": "FooElement",
          "documentation": {"href": "https://foo-library.com/api/FooElement.html"},
        }
      ]
    }
  ]
}

Additionally, in order to make a pre-flattened schema (where all transitive documentation links are inlined into a manifest, e.g. via pre-processing, to eliminate round-trips to fetch CEM's for referenced dependencies), DocumentationReference would be added as an optional property to Reference as well. This is similar in concept to the inheritedFrom option for class members.

As such, a valid my-foo CEM could include the canonical documentation link for the superclass:

{
  "modules": [
    {
      "kind": "javascript-module",
      "path": "my-foo.js",
      "declarations": [
        {
          "kind": "class",
          "name": "MyFoo",
          "superclass": {
            "name": "MyFoo",
            "package": "foo",
            "documentation": {"href": "https://foo-library.com/api/FooElement.html"}
          },
          ...
        }
      ]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant