Skip to content

Commit

Permalink
update links in documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jan 16, 2023
1 parent 60c0f9d commit 4776064
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
37 changes: 31 additions & 6 deletions lib/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,25 @@ export interface Plugin {
}

export interface PluginBuild {
/** Documentation: https://esbuild.github.io/plugins/#build-options */
initialOptions: BuildOptions;

/** Documentation: https://esbuild.github.io/plugins/#resolve */
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>;

/** Documentation: https://esbuild.github.io/plugins/#on-start */
onStart(callback: () =>
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;

/** Documentation: https://esbuild.github.io/plugins/#on-end */
onEnd(callback: (result: BuildResult) =>
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void;

/** Documentation: https://esbuild.github.io/plugins/#on-resolve */
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;

/** Documentation: https://esbuild.github.io/plugins/#on-load */
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void;

Expand All @@ -302,6 +312,7 @@ export interface PluginBuild {
};
}

/** Documentation: https://esbuild.github.io/plugins/#resolve-options */
export interface ResolveOptions {
pluginName?: string;
importer?: string;
Expand All @@ -311,6 +322,7 @@ export interface ResolveOptions {
pluginData?: any;
}

/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
export interface ResolveResult {
errors: Message[];
warnings: Message[];
Expand All @@ -333,11 +345,13 @@ export interface OnEndResult {
warnings?: PartialMessage[];
}

/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
export interface OnResolveOptions {
filter: RegExp;
namespace?: string;
}

/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
export interface OnResolveArgs {
path: string;
importer: string;
Expand All @@ -360,6 +374,7 @@ export type ImportKind =
| 'import-rule'
| 'url-token'

/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
export interface OnResolveResult {
pluginName?: string;

Expand All @@ -377,18 +392,21 @@ export interface OnResolveResult {
watchDirs?: string[];
}

/** Documentation: https://esbuild.github.io/plugins/#on-load-options */
export interface OnLoadOptions {
filter: RegExp;
namespace?: string;
}

/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
export interface OnLoadArgs {
path: string;
namespace: string;
suffix: string;
pluginData: any;
}

/** Documentation: https://esbuild.github.io/plugins/#on-load-results */
export interface OnLoadResult {
pluginName?: string;

Expand Down Expand Up @@ -418,6 +436,7 @@ export interface PartialNote {
location?: Partial<Location> | null;
}

/** Documentation: https://esbuild.github.io/api/#metafile */
export interface Metafile {
inputs: {
[path: string]: {
Expand Down Expand Up @@ -466,9 +485,15 @@ export interface WatchOptions {
}

export interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> {
/** Documentation: https://esbuild.github.io/api/#rebuild */
rebuild(): Promise<BuildResult<SpecificOptions>>

/** Documentation: https://esbuild.github.io/api/#watch */
watch(options?: WatchOptions): void

/** Documentation: https://esbuild.github.io/api/#serve */
serve(options?: ServeOptions): Promise<ServeResult>

dispose(): Promise<void>
}

Expand All @@ -480,7 +505,7 @@ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOption
* - Works in node: yes
* - Works in browser: yes
*
* Documentation: https://esbuild.github.io/api/#build-api
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>>;
export declare function build(options: BuildOptions): Promise<BuildResult>;
Expand All @@ -492,7 +517,7 @@ export declare function build(options: BuildOptions): Promise<BuildResult>;
* - Works in node: yes
* - Works in browser: no
*
* Documentation: https://esbuild.github.io/api/#context-api
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>>;
export declare function context(options: BuildOptions): Promise<BuildContext>;
Expand All @@ -506,7 +531,7 @@ export declare function context(options: BuildOptions): Promise<BuildContext>;
* - Works in node: yes
* - Works in browser: yes
*
* Documentation: https://esbuild.github.io/api/#transform-api
* Documentation: https://esbuild.github.io/api/#transform
*/
export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>>;
export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
Expand Down Expand Up @@ -539,7 +564,7 @@ export declare function analyzeMetafile(metafile: Metafile | string, options?: A
* - Works in node: yes
* - Works in browser: no
*
* Documentation: https://esbuild.github.io/api/#build-api
* Documentation: https://esbuild.github.io/api/#build
*/
export declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions>;
export declare function buildSync(options: BuildOptions): BuildResult;
Expand All @@ -550,7 +575,7 @@ export declare function buildSync(options: BuildOptions): BuildResult;
* - Works in node: yes
* - Works in browser: no
*
* Documentation: https://esbuild.github.io/api/#transform-api
* Documentation: https://esbuild.github.io/api/#transform
*/
export declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions>;
export declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult;
Expand Down Expand Up @@ -581,7 +606,7 @@ export declare function analyzeMetafileSync(metafile: Metafile | string, options
* - Works in node: yes
* - Works in browser: yes ("options" is required)
*
* Documentation: https://esbuild.github.io/api/#running-in-the-browser
* Documentation: https://esbuild.github.io/api/#browser
*/
export declare function initialize(options: InitializeOptions): Promise<void>;

Expand Down
44 changes: 33 additions & 11 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ type OutputFile struct {
Contents []byte
}

// Documentation: https://esbuild.github.io/api/#build-api
// Documentation: https://esbuild.github.io/api/#build
func Build(options BuildOptions) BuildResult {
start := time.Now()

Expand Down Expand Up @@ -451,7 +451,7 @@ type TransformResult struct {
MangleCache map[string]interface{}
}

// Documentation: https://esbuild.github.io/api/#transform-api
// Documentation: https://esbuild.github.io/api/#transform
func Transform(input string, options TransformOptions) TransformResult {
return transformImpl(input, options)
}
Expand Down Expand Up @@ -483,16 +483,19 @@ type ServeResult struct {
Host string
}

type OnChangeArgs struct {
}

type WatchOptions struct {
}

type BuildContext interface {
// Documentation: https://esbuild.github.io/api/#rebuild
Rebuild() BuildResult

// Documentation: https://esbuild.github.io/api/#watch
Watch(options WatchOptions) error

// Documentation: https://esbuild.github.io/api/#serve
Serve(options ServeOptions) (ServeResult, error)

Dispose()
}

Expand All @@ -507,7 +510,7 @@ func (err *ContextError) Error() string {
return "Context creation failed"
}

// Documentation: https://esbuild.github.io/api/#context-api
// Documentation: https://esbuild.github.io/api/#build
func Context(buildOptions BuildOptions) (BuildContext, *ContextError) {
ctx, errors := contextImpl(buildOptions)
if ctx == nil {
Expand All @@ -532,14 +535,26 @@ type Plugin struct {
}

type PluginBuild struct {
// Documentation: https://esbuild.github.io/plugins/#build-options
InitialOptions *BuildOptions
Resolve func(path string, options ResolveOptions) ResolveResult
OnStart func(callback func() (OnStartResult, error))
OnEnd func(callback func(result *BuildResult) (OnEndResult, error))
OnResolve func(options OnResolveOptions, callback func(OnResolveArgs) (OnResolveResult, error))
OnLoad func(options OnLoadOptions, callback func(OnLoadArgs) (OnLoadResult, error))

// Documentation: https://esbuild.github.io/plugins/#resolve
Resolve func(path string, options ResolveOptions) ResolveResult

// Documentation: https://esbuild.github.io/plugins/#on-start
OnStart func(callback func() (OnStartResult, error))

// Documentation: https://esbuild.github.io/plugins/#on-end
OnEnd func(callback func(result *BuildResult) (OnEndResult, error))

// Documentation: https://esbuild.github.io/plugins/#on-resolve
OnResolve func(options OnResolveOptions, callback func(OnResolveArgs) (OnResolveResult, error))

// Documentation: https://esbuild.github.io/plugins/#on-load
OnLoad func(options OnLoadOptions, callback func(OnLoadArgs) (OnLoadResult, error))
}

// Documentation: https://esbuild.github.io/plugins/#resolve-options
type ResolveOptions struct {
PluginName string
Importer string
Expand All @@ -549,6 +564,7 @@ type ResolveOptions struct {
PluginData interface{}
}

// Documentation: https://esbuild.github.io/plugins/#resolve-results
type ResolveResult struct {
Errors []Message
Warnings []Message
Expand All @@ -571,11 +587,13 @@ type OnEndResult struct {
Warnings []Message
}

// Documentation: https://esbuild.github.io/plugins/#on-resolve-options
type OnResolveOptions struct {
Filter string
Namespace string
}

// Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments
type OnResolveArgs struct {
Path string
Importer string
Expand All @@ -585,6 +603,7 @@ type OnResolveArgs struct {
PluginData interface{}
}

// Documentation: https://esbuild.github.io/plugins/#on-resolve-results
type OnResolveResult struct {
PluginName string

Expand All @@ -602,18 +621,21 @@ type OnResolveResult struct {
WatchDirs []string
}

// Documentation: https://esbuild.github.io/plugins/#on-load-options
type OnLoadOptions struct {
Filter string
Namespace string
}

// Documentation: https://esbuild.github.io/plugins/#on-load-arguments
type OnLoadArgs struct {
Path string
Namespace string
Suffix string
PluginData interface{}
}

// Documentation: https://esbuild.github.io/plugins/#on-load-results
type OnLoadResult struct {
PluginName string

Expand Down

0 comments on commit 4776064

Please sign in to comment.