Skip to content
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

generate v0.0.1 #1

Merged
merged 24 commits into from
Jun 3, 2023
Merged

generate v0.0.1 #1

merged 24 commits into from
Jun 3, 2023

Conversation

EthanThatOneKid
Copy link
Owner

This is a large PR intended to resolve EthanThatOneKid/dengen#1.

It consists of a module (mod.ts) and a CLI tool (main.ts).

@EthanThatOneKid EthanThatOneKid added the enhancement New feature or request label May 31, 2023
@EthanThatOneKid EthanThatOneKid changed the title deno_generate v0.0.1 generate v0.0.1 May 31, 2023
@EthanThatOneKid EthanThatOneKid marked this pull request as ready for review May 31, 2023 08:49
Copy link

@NfNitLoop NfNitLoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't have time to review every line, but the shape of things is good. Good docs, especially on your exported interfaces. 👍

My main questions are about the design:

  • Why do I want to put //deno:generate <command> in a TypeScript file instead of just in deno task?
  • If I have two files that depend on some generated code, which file do I put the annotation in?

examples/with_generate_docs.ts Outdated Show resolved Hide resolved
parse/parse.ts Outdated Show resolved Hide resolved
@EthanThatOneKid
Copy link
Owner Author

Thanks for taking the time to review, @NfNitLoop! I appreciate your feedback. Allow me to address the main questions.

Why do I want to put //deno:generate <command> in a TypeScript file instead of just in deno task?

Using //deno:generate <command> in a TypeScript file instead of solely relying on deno task offers several advantages. Firstly, incorporating //deno:generate directly into the source code allows for better integration between the generators and the codebase. This approach enables developers to easily understand and manage the generators as an integral part of the project.

Additionally, by utilizing //deno:generate, we can conveniently run multiple generators that are closely tied to the specific TypeScript files. While it's technically feasible to write a deno task that mimics the functionality of a series of //deno:generate commands, this approach may not scale efficiently when the project relies on numerous generators. By placing the //deno:generate directives within the relevant TypeScript files, we achieve a more scalable and flexible solution for managing generator-related tasks.

If two files rely on some generated code, it is recommended to make a shared module from which the two files can import the generated code.

In situations where multiple files depend on the same generated code, it's highly recommended to create a shared module. This shared module serves as a central location from which both files can import the generated code. By doing so, we promote better code organization and encourage code reuse.

The shared module approach also simplifies future modifications and updates. If the generated code needs to be modified or enhanced, we can make the changes in a single place—the shared module—and have the updates reflect in both files that depend on it. This not only reduces code duplication but also improves maintainability by ensuring consistency throughout the project.

I hope this clarifies the benefits of using //deno:generate in TypeScript files and the advantages of employing a shared module when dealing with generated code dependencies. Please let me know if you have any further questions or concerns.

- Add `examples/embedder`.
- Move docs example to `examples/docs`.
- Fix README.md typos.
- Add new FAQ section.
- Add sections from denoland/deno#19176: "Use cases", "Conventions", "Examples".
- Add `examples/embedder`.
- Move docs example to `examples/docs`.
- Fix README.md typos.
- Add new FAQ section.
- Add sections from denoland/deno#19176: "Use cases", "Conventions", "Examples".
@EthanThatOneKid EthanThatOneKid merged commit 1a310e7 into main Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add deno generate proof-of-concept
2 participants