daisy / ace

Ace by DAISY, an Accessibility Checker for EPUB
MIT License
74 stars 22 forks source link

Is there a way to use it programatically? #382

Closed michelem09 closed 1 year ago

michelem09 commented 1 year ago

I mean importing the package into an app and using it inside my own Node app without CLI or HTTP API.

michelem09 commented 1 year ago

Well I found it, for anyone who wants to use it programatically importing packages, here is:

yarn add @daisy/ace-core @daisy/ace-axe-runner-puppeteer

const ace = require('@daisy/ace-core');
const axeRunner = require('@daisy/ace-axe-runner-puppeteer');

const data = await ace(
  '/path/to/the/file.epub', // path
  { lang: 'en' }, // options
  axeRunner // engine
);
danielweck commented 1 year ago

That's right :) The CLI is really just a programmatic wrapper around the exposed API: https://github.com/daisy/ace/blob/master/packages/ace-cli/src/index.js ...with a bit of "sugar" to create an "executable": https://github.com/daisy/ace/blob/master/packages/ace-cli/bin/ace.js

michelem09 commented 1 year ago

Thanks! Would be great to have this in the doc too :-)