Skip to content

Add support for doc_id #732

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

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/model/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export class Endpoint {
name: string
description: string
docUrl: string
docId?: string
deprecation?: Deprecation

/**
Expand Down
5 changes: 4 additions & 1 deletion compiler/model/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export function hoistRequestAnnotations (
request: model.Request, jsDocs: JSDoc[], mappings: Record<string, model.Endpoint>, response: model.TypeName | null
): void {
const knownRequestAnnotations = [
'since', 'rest_spec_name', 'stability', 'visibility', 'behavior', 'class_serializer'
'since', 'rest_spec_name', 'stability', 'visibility', 'behavior', 'class_serializer', 'doc_id'
]
// in most of the cases the jsDocs comes in a single block,
// but it can happen that the user defines multiple single line jsDoc.
Expand Down Expand Up @@ -556,6 +556,9 @@ export function hoistRequestAnnotations (
} else if (tag === 'since') {
assert(jsDocs, semver.valid(value), `Request ${request.name.name}'s @since is not valid semver: ${value}`)
endpoint.since = value
} else if (tag === 'doc_id') {
assert(jsDocs, value.trim() !== '', `Request ${request.name.name}'s @doc_id is cannot be empty`)
endpoint.docId = value
} else {
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
}
Expand Down
15 changes: 15 additions & 0 deletions docs/modeling-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@ class Foo {
}
```

#### `@doc_id`

The documentation id that can be used for generating the doc url.
See [#714](https://github.com/elastic/elasticsearch-specification/issues/714) for context.

```ts
/**
* @rest_spec_name api
* @doc_id foobar
*/
class Request {
...
}
```

#### `@identifier`

A custom name that can be used to display the property. Useful in Enums an
Expand Down