Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs(ast-spec): add script to generates code strings for the doc files#3248

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
bradzacher wants to merge2 commits intomainfromseparate-spec-doc-generator

Conversation

@bradzacher
Copy link
Member

@bradzacherbradzacher commentedMar 30, 2021
edited
Loading

I'm not sure if we will want to actually use this or not.
This was just an idea I had to allow us to embed the relevant code samples directly in a.md file saving consumers from having to switch between the .ts file and the .md file.

We could ofc just embed the file itself, but that's not as nice because:

  • there's the extra cruft ofexport keywords.
  • there's the extra cruft of theimport statements.
  • some nodes are a union of different types for different usecases.
    • egClassProperty is a union of two typesClassPropertyComputedName andClassPropertyNonComputedName
  • some nodes extend base nodes in other files
    • eg for the sameClassProperty case both the types extend base classes of similar names.
    • these types are pretty impossible to understand from the github UI (but are easy to interrogate from an IDE).

We may end up just ditching this... but it was worth putting it up for posterity.

As an example - this script generates the following output forClassProperty:

interfaceClassPropertyComputedNameextendsBaseNode{type:'ClassProperty';key:Expression;computed:true;value:Expression|null;static:boolean;declare:boolean;readonly?:boolean;decorators?:Decorator[];accessibility?:"private"|"protected"|"public";optional?:boolean;definite?:boolean;typeAnnotation?:TSTypeAnnotation;}interfaceClassPropertyNonComputedNameextendsBaseNode{type:'ClassProperty';key:Identifier|NumberLiteral|StringLiteral;computed:false;value:Expression|null;static:boolean;declare:boolean;readonly?:boolean;decorators?:Decorator[];accessibility?:"private"|"protected"|"public";optional?:boolean;definite?:boolean;typeAnnotation?:TSTypeAnnotation;}typeClassProperty=|ClassPropertyComputedName|ClassPropertyNonComputedName;

sosukesuzuki reacted with thumbs up emoji
@bradzacherbradzacher added DO NOT MERGEPRs which should not be merged yet documentationDocumentation ("docs") that needs adding/updating labelsMar 30, 2021
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day.

@bradzacherbradzacher changed the titlefeat: refactor to split AST specification out as its own moduledocs(ast-spec): add script to generates code strings for the doc filesMar 30, 2021
@bradzacherbradzacherforce-pushed theseparate-spec-doc-generator branch fromd061042 tob00a8ccCompareMarch 30, 2021 21:39
Fixes#2726Fixes#2912This PR is the basis for a big cleanup and reorganisation of the AST.This first step takes the file `types/src/ts-estree.ts` and splits it up in its entirety.This file was a monolith at 1700 lines - meaning it was a pain to organise and manage, and there was no way to isolate/restrict certain things (aside from adding comments).This PR should ultimately be a no-op - there should be no breaking changes here.I did fix up a number of types which I found when organising files into their folders.Whilst this PR ultimately creates more LOC, the isolation enables a few things:- By splitting the AST into its own module, it's isolated so easier to manage / govern- By splitting each AST node into its own folder we can cleanly document and link to individual node specs- By grouping nodes decls by folder, it's easier to inspect the types to validate unions are correct.    - I found a number of invalid nodes in unions in this PR which have been fixed.- In a future PR we can:    - Add lint rule(s) to validate unions are correct (eg ensure all `Expression` types are included in the `Expression` union).    - Easily add documentation about the node without cluttering things up    - Colocate fixtures/snapshots with the node specs to document the cases that we expect a node to show up    - Colocate the conversion logic here so that it's easier to validate that the spec and the conversion logic are in sync        - This will make it much easier to implement and maintain#1852
I'm not sure if we will want to actually use this or not.This was just an idea I had to allow us to embed the relevant code samples directly in a `.md` file saving consumers from having to switch between the .ts file and the .md file.We could ofc just embed the file itself, but that's not as elegant as there's the extra cruft of `export` and  `import`s.May end up just ditching this... but it was worth putting it up for posterity.As an� example - this script generates the following output for `ClassProperty.ts`:```tsinterface ClassPropertyComputedName extends BaseNode {  type: 'ClassProperty';  key: Expression;  computed: true;  value: Expression | null;  static: boolean;  declare: boolean;  readonly?: boolean;  decorators?: Decorator[];  accessibility?: "private" | "protected" | "public";  optional?: boolean;  definite?: boolean;  typeAnnotation?: TSTypeAnnotation;}interface ClassPropertyNonComputedName extends BaseNode {  type: 'ClassProperty';  key: Identifier | NumberLiteral | StringLiteral;  computed: false;  value: Expression | null;  static: boolean;  declare: boolean;  readonly?: boolean;  decorators?: Decorator[];  accessibility?: "private" | "protected" | "public";  optional?: boolean;  definite?: boolean;  typeAnnotation?: TSTypeAnnotation;}type ClassProperty =  | ClassPropertyComputedName  | ClassPropertyNonComputedName;```
@bradzacherbradzacherforce-pushed theseparate-spec-doc-generator branch fromb00a8cc tof1b42daCompareMarch 30, 2021 21:41
@bradzacherbradzacherforce-pushed theseparate-spec branch 2 times, most recently from3f04cd5 toa5f8933CompareMay 4, 2021 22:18
Base automatically changed fromseparate-spec tomasterMay 4, 2021 23:15
@bradzacherbradzacher added the stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelMar 4, 2022
@bradzacherbradzacher deleted the separate-spec-doc-generator branchMarch 4, 2022 07:41
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMay 25, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

DO NOT MERGEPRs which should not be merged yetdocumentationDocumentation ("docs") that needs adding/updatingstalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp