-
Notifications
You must be signed in to change notification settings - Fork 167
docs: add API extractor #354
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8f0d89f
docs: add API extractor
grant f5078fc
ci: fix lint
grant 82d5b9e
feat: update api extractor setup
grant 40ce4a5
fix: remove temp files
grant 5c6c941
refactor: move generated docs to generated section
grant 70ed5bf
docs: update contributing doc path
grant 67cded4
fix: export Data as well
grant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ yarn-error.log | |
function_output.json | ||
serverlog_stderr.txt | ||
serverlog_stdout.txt | ||
temp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,16 @@ npm unpublish @google-cloud/[email protected] | |
npm dist-tag add @google-cloud/[email protected] latest --registry=https://wombat-dressing-room.appspot.com | ||
``` | ||
|
||
### API Extractor | ||
|
||
To generate the API Extractor documentation, run the API extractor with the following command: | ||
|
||
```sh | ||
npm run docs | ||
``` | ||
|
||
The docs will be generated in [`docs/generated/`](docs/generated/). | ||
|
||
## Community Guidelines | ||
|
||
This project follows [Google's Open Source Community | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
|
||
"mainEntryPointFilePath": "build/src/index.d.ts", | ||
"bundledPackages": [], | ||
"compiler": { | ||
"tsconfigFilePath": "tsconfig.json" | ||
}, | ||
"apiReport": { | ||
"enabled": true, | ||
"reportFolder": "docs/generated/", | ||
"reportFileName": "api.md" | ||
}, | ||
|
||
"docModel": { | ||
"enabled": true, | ||
"apiJsonFilePath": "docs/generated/api.json" | ||
}, | ||
|
||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "docs/generated/api.d.ts", | ||
"omitTrimmingComments": true | ||
}, | ||
|
||
"tsdocMetadata": { | ||
}, | ||
|
||
"messages": { | ||
"compilerMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
} | ||
}, | ||
|
||
"extractorMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
} | ||
}, | ||
|
||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import * as express from 'express'; | ||
|
||
/** | ||
* Register a function that handles CloudEvents. | ||
* @param functionName - the name of the function | ||
* @param handler - the function to trigger when handling cloudevents | ||
* @public | ||
*/ | ||
export declare const cloudevent: (functionName: string, handler: CloudEventFunction) => void; | ||
|
||
/** | ||
* A cloudevent function handler. | ||
* @public | ||
*/ | ||
export declare interface CloudEventFunction { | ||
(cloudevent: CloudEventsContext): any; | ||
} | ||
|
||
/** | ||
* A cloudevent function handler with callback. | ||
* @public | ||
*/ | ||
export declare interface CloudEventFunctionWithCallback { | ||
(cloudevent: CloudEventsContext, callback: Function): any; | ||
} | ||
|
||
/** | ||
* The CloudEvents v1.0 context object for the event. | ||
* {@link https://github.com/cloudevents/spec/blob/master/spec.md#context-attributes} | ||
* @public | ||
*/ | ||
export declare interface CloudEventsContext { | ||
/** | ||
* Type of occurrence which has happened. | ||
*/ | ||
type?: string; | ||
/** | ||
* The version of the CloudEvents specification which the event uses. | ||
*/ | ||
specversion?: string; | ||
/** | ||
* The event producer. | ||
*/ | ||
source?: string; | ||
/** | ||
* ID of the event. | ||
*/ | ||
id?: string; | ||
/** | ||
* Timestamp of when the event happened. | ||
*/ | ||
time?: string; | ||
/** | ||
* Describes the subject of the event in the context of the event producer. | ||
*/ | ||
subject?: string; | ||
/** | ||
* A link to the schema that the event data adheres to. | ||
*/ | ||
dataschema?: string; | ||
/** | ||
* Content type of the event data. | ||
*/ | ||
datacontenttype?: string; | ||
/** | ||
* The event data. | ||
*/ | ||
data?: Record<string, unknown | string | number | boolean> | string | number | boolean | null | unknown; | ||
/** | ||
* The traceparent string, containing a trace version, trace ID, span ID, and trace options. | ||
* @see https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md | ||
*/ | ||
traceparent?: string; | ||
} | ||
|
||
/** | ||
* The Cloud Functions context object for the event. | ||
* {@link https://cloud.google.com/functions/docs/writing/background#function_parameters} | ||
* @public | ||
*/ | ||
export declare interface CloudFunctionsContext { | ||
/** | ||
* A unique ID for the event. For example: "70172329041928". | ||
*/ | ||
eventId?: string; | ||
/** | ||
* The date/time this event was created. For example: "2018-04-09T07:56:12.975Z" | ||
* This will be formatted as ISO 8601. | ||
*/ | ||
timestamp?: string; | ||
/** | ||
* The type of the event. For example: "google.pubsub.topic.publish". | ||
*/ | ||
eventType?: string; | ||
/** | ||
* The resource that emitted the event. | ||
*/ | ||
resource?: string | { | ||
[key: string]: string; | ||
}; | ||
} | ||
|
||
/** | ||
* The function's context. | ||
* @public | ||
*/ | ||
export declare type Context = CloudFunctionsContext | CloudEventsContext; | ||
|
||
/** | ||
* A data object used for legacy event functions. | ||
* @public | ||
*/ | ||
export declare interface Data { | ||
data: object; | ||
} | ||
|
||
/** | ||
* A legacy event function handler. | ||
* @public | ||
*/ | ||
export declare interface EventFunction { | ||
(data: {}, context: Context): any; | ||
} | ||
|
||
/** | ||
* A legacy event function handler with callback. | ||
* @public | ||
*/ | ||
export declare interface EventFunctionWithCallback { | ||
(data: {}, context: Context, callback: Function): any; | ||
} | ||
|
||
/** | ||
* A function handler. | ||
* @public | ||
*/ | ||
export declare type HandlerFunction = HttpFunction | EventFunction | EventFunctionWithCallback | CloudEventFunction | CloudEventFunctionWithCallback; | ||
|
||
/** | ||
* Register a function that responds to HTTP requests. | ||
* @param functionName - the name of the function | ||
* @param handler - the function to invoke when handling HTTP requests | ||
* @public | ||
*/ | ||
export declare const http: (functionName: string, handler: HttpFunction) => void; | ||
|
||
/** | ||
* A HTTP function handler. | ||
* @public | ||
*/ | ||
export declare interface HttpFunction { | ||
(req: express.Request, res: express.Response): any; | ||
} | ||
|
||
/** | ||
* A legacy event function context. | ||
* @public | ||
*/ | ||
export declare type LegacyCloudFunctionsContext = CloudFunctionsContext | Data; | ||
|
||
/** | ||
* A legacy event. | ||
* @public | ||
*/ | ||
export declare interface LegacyEvent { | ||
data: { | ||
[key: string]: any; | ||
}; | ||
context: CloudFunctionsContext; | ||
} | ||
|
||
export { } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we eventually want to actually make this the
types
we use in ourpackage.json
file.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.
Sure, that's fine. There would need to be some script or tooling to update this generated file with
package.json
types.Or we could simply not generate this file.