Giter Club home page Giter Club logo

ts-morph-structures's People

Contributors

ajvincent avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ts-morph-structures's Issues

Tighten structure types feeding MultiMixinBuilder

Whoops. The mixin classes implement the tighter property definitions I want, but the type definitions constraining them are the original ones from ts-morph. This caused a test I was going to port from stage 1 to stage 2 for #21 to just blow up with TypeScript errors.

Easy fix, but I need to remember to actually do the fix.

Add TSDoc comments to structure classes

Hi, everyone! One nice-to-have for this project is code documentation. I've built a tool to generate it, but it needs data.

TSDocMap is a definition of TSDoc comments for structure and decorator classes which don't exist until later stages. Here's one example of the output.

I need help with people going through the stage 2 snapshot files and filling in the blanks, so to speak.

Here's how to get started:

  1. Do a git clone of this repository, and run npm install.
  2. Run npm run build. This will generate stage_2_fullset/snapshot/coverage/tsdocs.json, which is git-ignored. The output describes the current documentation state.
  3. Update TSDocMap with your new metadata.
  4. Run npm run build again to see the results.
  5. Submit a pull request!

There's a special wildcard, className: "*", which should apply changes across all decorators or all structures. static [COPY_FIELDS] is a good use-case for this, as it's supposed to be @internal.

During your npm run build commands, you may notice a "Coverage report: TSDoc comments" section. This is specifically checking for completeness in the documentation. Green dots are good. Yellow slashes are incomplete, and red X's are missing altogether.

Thanks!

(Clarification: I do not expect one person to do every single structure class and every single decorator class. This really is a tracking ticket for a bunch of pull requests...)

Create "boolean" class decorators

Several of the class decorators I built for the prototype were just adding single boolean properties, and applying them in clone operations. It'd be better to have a simple JSON file to specify what structures define simple boolean mix-ins. Then it's a simple matter of testing one. If one works, all of them work.

Stage 3 needs a convergence report

As I develop this, I need some way of measuring how closely stage 3's snapshot is converging on stage 2's snapshot. Various things I need to check for:

  • Missing files
  • Extra files
  • Base files not matching
  • Missing or different class properties (type, initializer)
  • Static methods missed or different (parameter names, types, return type, body)
  • Constructor missed or different (parameter names, types, return type, body)
  • Missing or different TSDoc comments
  • Missing or different Markdown documentation
  • Decorators: wrapper function different parameters, return type, body
  • Structures: mixin class different
  • Hash of file

There should be three modes of output:

  • Console with ANSI color-escaped characters
  • Markdown file for details
  • JSON file for Jasmine tests to check

Expose type structures on mixins

A mix-in decorator class may have properties like typeStructure, but if we don't report that in the decorator class's fields, TypeScript won't know about it.

Write a README file.

In particular, when people should use the structures ("new code"), versus when they should directly use ts-morph ("existing code").

Add `NumberTypeStructureImpl`

It would be a very good replacement for LiteralTypeStructureImpl, especially since it's easier to check type: number than type: string.

Edit: Maybe not a replacement. I'm rethinking the deprecation of LiteralTypeStructureImpl.

Add source/utilities/public for useful public exports

Certain existing build utilities (ImportManager, ExportManager, probably ClassMembersMap) are proving useful enough to make part of the source code. Others, such as a type-to-class feature (#13), and a structures factory (#5) are going to be useful in the future.

Export a StructuresFactory module

export function createSourceFile(...): SourceFileImpl {
}

export function createClassDeclaration(...): ClassDeclarationImpl {
}

Then, in exports.ts,

export * as StructuresFactory from "./snapshot/StructuresFactory.js";

How to generate GitHub Pages documentation?

I've reserved snapshot/docs for drafting GitHub Pages documentation. I need to be able to show the impact of changing structure fields.

One possibility: GitHub Markdown supports the diff language.

See #6 for TSDoc.

Add stage_2_docs build subproject

I've been struggling conceptually about how to generate code samples for these class structures. One option I've been considering is using the stage 2 snapshot to modify itself.

So I'm going to create a stage_2_docs directory, whose sole purpose is to host two copies of the output from stage 1. The first copy I'll use to modify the second copy, adding documentation. The second copy will go on to become the stage 2 snapshot.

Bonus: more dogfooding.

How to generate TSDoc comments?

This tool is centered on generating the structures classes via ts-morph and using existing structure classes. The downside is this means it will be harder to create human-readable documentation, including tsdoc and examples of each structure's attributes impact on the resulting generated code.

For instance, it's obvious what AsyncableNodeStructure provides: an isAsync attribute for adding the async keyword. But if you don't know this field exists, how are you going to discover it, or what its value does to ts-morph?

A not-so-obvious example is assertElements from ImportDeclarationImpl. The prototype snapshot initially thought this had to be defined as an array, but this led to unexpected assert {} at the end of the import statement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.