-
Notifications
You must be signed in to change notification settings - Fork 877
feat: Generic API page schema #9267
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||
| // Licensed to the .NET Foundation under one or more agreements. | ||||||
| // The .NET Foundation licenses this file to you under the MIT license. | ||||||
|
|
||||||
| /** | ||||||
| * This file is used to generate the API page JSON schema. To generate the schema: | ||||||
| * 1. run `npx typescript-json-schema ApiPage.schema.d.ts ApiPage --required --strictNullChecks --out ApiPage.schema.json` | ||||||
| * 2. manually mark properties as markdown | ||||||
| */ | ||||||
|
|
||||||
| /** Define the markdown content type */ | ||||||
| type markdown = string; | ||||||
|
|
||||||
| /** Represents an inline composed of text or links */ | ||||||
| type Inline = string | (string | { text: string; url?: string })[]; | ||||||
|
|
||||||
| /** Represents a markdown block */ | ||||||
| type Markdown = { | ||||||
| /** Markdown content */ | ||||||
| markdown: markdown; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents a heading */ | ||||||
| type Heading = | ||||||
| | { /** Heading title */ h1: string; /** URL fragment */ id?: string } | ||||||
| | { /** Heading title */ h2: string; /** URL fragment */ id?: string } | ||||||
| | { /** Heading title */ h3: string; /** URL fragment */ id?: string } | ||||||
| | { /** Heading title */ h4: string; /** URL fragment */ id?: string } | ||||||
| | { /** Heading title */ h5: string; /** URL fragment */ id?: string } | ||||||
| | { /** Heading title */ h6: string; /** URL fragment */ id?: string }; | ||||||
|
|
||||||
| /** Represents an API heading */ | ||||||
| type Api = ( | ||||||
| | { /** API name */ api1: string } | ||||||
| | { /** API name */ api2: string } | ||||||
| | { /** API name */ api3: string } | ||||||
| | { /** API name */ api4: string } | ||||||
| ) & { | ||||||
| /** API URL fragment */ | ||||||
| id?: string; | ||||||
|
|
||||||
| /** Is this API deprecated, or the deprecation reason */ | ||||||
| deprecated?: boolean | string; | ||||||
|
|
||||||
| /** API source URL */ | ||||||
| src?: string; | ||||||
|
|
||||||
| /** Opaque metadata about the API as HTML data-* attributes */ | ||||||
| metadata?: { [key: string]: string }; | ||||||
|
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not clear whether the "data-" prefix is part of the key here, or added during the conversion to HTML.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| }; | ||||||
|
|
||||||
| /** Represents a sheet of facts */ | ||||||
| type Facts = { | ||||||
| facts: { | ||||||
| name: string; | ||||||
| value: Inline; | ||||||
| }[]; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents a list of content */ | ||||||
| type List = { | ||||||
| list: Inline[]; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents a single inheritance chain from base type to derived type */ | ||||||
| type Inheritance = { | ||||||
| inheritance: Inline[]; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents a code block */ | ||||||
| type Code = { | ||||||
| /** Code text */ | ||||||
| code: string; | ||||||
|
|
||||||
| /** Code [langauge identifier](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) */ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| languageId?: string; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents a set of parameters */ | ||||||
| type Params = { | ||||||
| parameters: { | ||||||
| /** Parameter name */ | ||||||
| name?: string; | ||||||
|
|
||||||
| /** Parameter type */ | ||||||
| type?: Inline; | ||||||
|
|
||||||
| /** Parameter default value */ | ||||||
| default?: string; | ||||||
|
|
||||||
| /** Parameter description in markdown format */ | ||||||
| description?: markdown; | ||||||
|
|
||||||
| /** Is this parameter deprecated, or the deprecation reason */ | ||||||
| deprecated?: boolean | string; | ||||||
|
|
||||||
| /** Is this parameter optional? */ | ||||||
| optional?: boolean; | ||||||
| }[]; | ||||||
| }; | ||||||
|
|
||||||
| /** Represents block level elements */ | ||||||
| type Block = | ||||||
| | Heading | ||||||
| | Api | ||||||
| | Markdown | ||||||
| | Facts | ||||||
| | Params | ||||||
| | List | ||||||
| | Inheritance | ||||||
| | Code; | ||||||
|
|
||||||
| /** Represents a general API page */ | ||||||
| type ApiPage = { | ||||||
| /** Page title */ | ||||||
| title: string; | ||||||
|
|
||||||
| /** Opaque metadata about the page as HTML <meta> tags */ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Willl this documentation be parsed as Markdown? If so,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, properties using markdown formats are explicitly typed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant the documentation of the property, not the value of the property. /** Opaque metadata about the page as HTML `<meta>` tags */because you used Markdown syntax for hyperlinks in the documentation of other properties. |
||||||
| metadata?: { [key: string]: string | string[] }; | ||||||
|
|
||||||
| /** Default code [language identifier](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) */ | ||||||
| languageId?: string; | ||||||
|
|
||||||
| /** Page body */ | ||||||
| body: Block[]; | ||||||
| }; | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "URL fragment" mean it is expected to match the fragment definition in https://www.rfc-editor.org/rfc/rfc3986#section-3.5? I.e. does not include
#, and can contain pct-encoded.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, renderers are not expected to change this
idto match rfc3986, renders MAY encode theidto produce valid HTML.