Skip to content

Commit

Permalink
feat: add generated code comments (#1037)
Browse files Browse the repository at this point in the history
Closes #531
  • Loading branch information
dasco144 authored May 1, 2024
1 parent 577def4 commit cdd4a76
Show file tree
Hide file tree
Showing 260 changed files with 1,587 additions and 22 deletions.
6 changes: 6 additions & 0 deletions integration/angular/simple-message.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/async-iterable-services-abort-signal/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/async-iterable-services/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-folder-name/ui.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-folder-name/ui/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-types-only/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-types-only/simple2.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts/simple2.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/barrel-imports/bar.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/barrel-imports/foo.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/batching-with-context-esModuleInterop/batching.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/batching-with-context/batching.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/batching/batching.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/before-after-request-streaming/example.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/before-after-request/simple.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/before-after-request/simple2.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/bytes-as-base64-browser/message.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/bytes-as-base64-node/message.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/bytes-as-base64/message.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/bytes-node/google/protobuf/wrappers.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/bytes-node/point.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions integration/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parse } from "path";
import { promisify } from "util";
import { generateFile, makeUtils } from "../src/main";
import { createTypeMap } from "../src/types";
import { generateIndexFiles } from "../src/utils";
import { generateIndexFiles, getVersions } from "../src/utils";
import { getTsPoetOpts, optionsFromParameter } from "../src/options";
import { BaseContext, createFileContext } from "../src/context";
import { generateTypeRegistry } from "../src/generate-type-registry";
Expand All @@ -28,6 +28,8 @@ async function generate(binFile: string, baseDir: string, parameter: string) {
const request = CodeGeneratorRequest.decode(stdin);
request.parameter = parameter;

const { protocVersion, tsProtoVersion } = await getVersions(request);

const options = optionsFromParameter(parameter || "");
const typeMap = createTypeMap(request, options);

Expand All @@ -42,7 +44,10 @@ async function generate(binFile: string, baseDir: string, parameter: string) {
const filePath = `${baseDir}/${path}`;
const dirPath = parse(filePath).dir;
await promisify(mkdir)(dirPath, { recursive: true }).catch(() => {});
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion, file.name), path }),
);
}

if (options.outputTypeRegistry) {
Expand All @@ -54,15 +59,21 @@ async function generate(binFile: string, baseDir: string, parameter: string) {

const filePath = `${baseDir}/${path}`;

await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion), path }),
);
}

if (options.outputIndex) {
for (const [path, code] of generateIndexFiles(request.protoFile, options)) {
const filePath = `${baseDir}/${path}`;
const dirPath = parse(filePath).dir;
await promisify(mkdir)(dirPath, { recursive: true }).catch(() => {});
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion), path }),
);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions integration/const-enum/const-enum.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/default-with-metadata/default-with-metadata.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/emit-default-values-json/test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/enums-as-literals/enums-as-literals.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/enums-with-unrecognized-name-value/test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/extensions/test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions integration/fieldmask-optional-all/fieldmask-optional.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cdd4a76

Please sign in to comment.