Skip to content

Can't get --extension to work. #891

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

Closed
gauntface opened this issue Aug 23, 2017 · 2 comments
Closed

Can't get --extension to work. #891

gauntface opened this issue Aug 23, 2017 · 2 comments

Comments

@gauntface
Copy link

With the following input file saved as index.js

import LogHelper from './internal/utils/LogHelper.mjs';

/**
 * WorkboxCore shares code across Workbox modules.
 * @module workbox-core
 */
class WorkboxCore {
  /**
   * Constructs a new WorkboxCore instance.
   */
  constructor() {
    this.INTERNAL = {
      logHelper: new LogHelper(),
    };
  }

  /**
   * This tests the documentation generation.
   */
  test() {

  }
}

export default new WorkboxCore();

I get the expected output:

$ documentation build packages/workbox-core/index.js -f md -e mjs
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [workbox-core](#workbox-core)
-   [constructor](#constructor)
-   [test](#test)

## workbox-core

WorkboxCore shares code across Workbox modules.

## constructor

Constructs a new WorkboxCore instance.

## test

This tests the documentation generation.

If I change the file extension to mjs and run the command again (With or without --extension mjs), I get no output

$ documentation build packages/workbox-core/index.mjs -f md -e mjs
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents
  • What version of documentation.js are you using?: 5.2.2
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI

Is there anyway to parse JS files with a different extension? .mjs will be used for future node modules so I suspect this will be a request sooner or later.

@tmcw
Copy link
Member

tmcw commented Aug 27, 2017

Sure, so - --extension is not an option - I need to update Usage to reflect this -the --help output is already correct.

Instead, the options are:

  --require-extension, --re  additional extensions to include in require() and
                             import's search algorithm.For instance, adding .es5
                             would allow require("adder") to find "adder.es5"
  --parse-extension, --pe    additional extensions to parse as source code.

In this case, you'd add both with mjs.

@gauntface
Copy link
Author

I think I got it working with:

documentation build packages/workbox-core/index.mjs -f md --require-extension mjs --parse-extension mjs

Note: It's mjs and not .mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants