Skip to content

Consider a better API for feeding in files #160

Open
@domenic

Description

@domenic

#159 ran into an issue where the current API is not flexible enough to do targeted testing, because it operates on a directory level. This has always been a bit of a strange design; it's not very flexible and assumes a lot about the directory structure. I'd love to get opinions on what would be better designs.

Here are some ideas:

const transformer = new WebIDL2JS();

transformer.addSource("path/to/Attr.webidl", "path/to/Attr-impl.js");
// ... add the rest, one file at a time. The client is responsible for directory iteration.

await transformer.generate("outputDir");
const transformer = new WebIDL2JS({
  implPath(webidlFilePath) { return ...; }
  wrapperPath(webidlFilePath, implPath) { return ...; }
});

transformer.addFile("webidlFilesDir/Attr.webidl");

// Optionally add some of these as convenience methods:
transformer.addDirectory("webidlFilesDir");
transformer.addFromGlob("webidlFilesDir/**.webidl");

await transformer.generate();

Other ideas are welcome as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions