Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: documentationjs/documentation
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v13.2.5
Choose a base ref
...
head repository: documentationjs/documentation
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.0.0
Choose a head ref

Commits on May 4, 2021

  1. refactoring (#1376)

    * refactor: replace leftPad on native implementation padStart
    
    * refactor: migrate on new Buffer API
    anthony-redFox authored May 4, 2021
    Copy the full SHA
    806defa View commit details

Commits on May 14, 2021

  1. refactor: use singleton config for execution

    It will be easy to not put config as parameter each time
    anthony-redFox committed May 14, 2021
    Copy the full SHA
    4b711da View commit details
  2. Copy the full SHA
    0e1172e View commit details

Commits on May 19, 2021

  1. Copy the full SHA
    f0cb1c0 View commit details
  2. Copy the full SHA
    3ba8165 View commit details

Commits on Aug 6, 2021

  1. Copy the full SHA
    90bcf0c View commit details

Commits on Oct 8, 2021

  1. build(deps): bump dependencies

    Signed-off-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
    Co-Authored-By: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-Authored-By: Matthieu MOREL <mmorel-35@users.noreply.github.com>
    2 people authored and anthony-redFox committed Oct 8, 2021
    Copy the full SHA
    f229cb7 View commit details
  2. build(deps-dev): bump lint-staged from 11.1.2 to 11.2.0

    Bumps [lint-staged](https://github.com/okonet/lint-staged) from 11.1.2 to 11.2.0.
    - [Release notes](https://github.com/okonet/lint-staged/releases)
    - [Commits](lint-staged/lint-staged@v11.1.2...v11.2.0)
    
    ---
    updated-dependencies:
    - dependency-name: lint-staged
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Oct 8, 2021
    Copy the full SHA
    e758ae3 View commit details
  3. build(deps): bump @babel/core from 7.15.4 to 7.15.8

    Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.15.4 to 7.15.8.
    - [Release notes](https://github.com/babel/babel/releases)
    - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/babel/babel/commits/v7.15.8/packages/babel-core)
    
    ---
    updated-dependencies:
    - dependency-name: "@babel/core"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Oct 8, 2021
    Copy the full SHA
    80e306f View commit details

Commits on Oct 12, 2021

  1. Copy the full SHA
    ed48723 View commit details
  2. chore: Update Node minimum version to 14

    BREAKING CHANGE:
    documentation.js will now require node 14 or later.
    anthony-redFox committed Oct 12, 2021
    Copy the full SHA
    fc0bb3c View commit details

Commits on Oct 19, 2021

  1. remove greenkeeper from package.json

    No longer needed since dependabot is used instead
    coliff authored and anthony-redFox committed Oct 19, 2021
    Copy the full SHA
    61fc1b6 View commit details
  2. Copy the full SHA
    05026ce View commit details
  3. Copy the full SHA
    d604f29 View commit details
  4. Copy the full SHA
    aa24a1b View commit details
  5. Copy the full SHA
    245837f View commit details

Commits on Oct 20, 2021

  1. Copy the full SHA
    db74e7c View commit details
  2. build(deps): bump strip-json-comments from 2.0.1 to 4.0.0

    Bumps [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) from 2.0.1 to 4.0.0.
    - [Release notes](https://github.com/sindresorhus/strip-json-comments/releases)
    - [Commits](sindresorhus/strip-json-comments@v2.0.1...v4.0.0)
    
    ---
    updated-dependencies:
    - dependency-name: strip-json-comments
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Oct 20, 2021
    Copy the full SHA
    bae3030 View commit details
  3. build(deps-dev): bump standard-version from 9.3.1 to 9.3.2

    Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 9.3.1 to 9.3.2.
    - [Release notes](https://github.com/conventional-changelog/standard-version/releases)
    - [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md)
    - [Commits](conventional-changelog/standard-version@v9.3.1...v9.3.2)
    
    ---
    updated-dependencies:
    - dependency-name: standard-version
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Oct 20, 2021
    Copy the full SHA
    e4d8a7c View commit details

Commits on Oct 21, 2021

  1. deps: update yargs

    anthony-redFox committed Oct 21, 2021
    Copy the full SHA
    6f6f9d0 View commit details
  2. Copy the full SHA
    874069c View commit details

Commits on Oct 22, 2021

  1. fix: html report, it is return html if output is not defined

    Html report should be encapsulated and not return all files to save it.
    anthony-redFox committed Oct 22, 2021
    Copy the full SHA
    0975871 View commit details
  2. Copy the full SHA
    9da4567 View commit details

Commits on Oct 25, 2021

  1. fix: The server parameter deprecated and will be remove in next Major…

    … version fixed #1413
    
    BREAKING CHANGE:
    The serve parametr was remove, you can use any other tools which could be refresh and store your html site
    The private parameter has removed, use a access
    anthony-redFox committed Oct 25, 2021
    Copy the full SHA
    810e08b View commit details

Commits on Oct 26, 2021

  1. build(deps-dev): bump eslint from 8.0.1 to 8.1.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.0.1 to 8.1.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](eslint/eslint@v8.0.1...v8.1.0)
    
    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Oct 26, 2021
    Copy the full SHA
    66fbbbe View commit details

Commits on Oct 28, 2021

  1. Copy the full SHA
    d88a14d View commit details
  2. Copy the full SHA
    61ed5dd View commit details

Commits on Nov 10, 2021

  1. fix: use process.cwd vs . which can fail

    When '.' does not work, this utility function outside the runtime closure can yield an unhelpful error for consumers.
    DavideDaniel authored and anthony-redFox committed Nov 10, 2021
    Copy the full SHA
    4cc70a5 View commit details

Commits on Nov 11, 2021

  1. fix: external was removed as prefer of input usages

    BREAKING CHANGE:
    external parameter was removed
    Migration plan propose to move all external resources to input usages
    Motivation: packages has many inputs which describe in package.json
    so that mean need each time to parse all package.json of exsternal resources to understand which etry point need to pick.
    But it is base on guesses because entry point may could not contains a documentation and the best way to handle it manualy.
    anthony-redFox committed Nov 11, 2021
    Copy the full SHA
    e3c59d7 View commit details
  2. refactor: replace module-deps-sortable on own implementation to contr…

    …ol how parse files
    
    BREAKING CHANGE:
    all Extensions whould contains '.' so that mean if you have just 'ts' then need to convert to '.ts'
    anthony-redFox committed Nov 11, 2021
    3
    Copy the full SHA
    abb781a View commit details
  3. Copy the full SHA
    4ce3035 View commit details
  4. Copy the full SHA
    77c6f76 View commit details
  5. build(deps-dev): bump eslint from 8.1.0 to 8.2.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.1.0 to 8.2.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](eslint/eslint@v8.1.0...v8.2.0)
    
    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 11, 2021
    Copy the full SHA
    bec8af4 View commit details
  6. build(deps-dev): bump json-schema from 0.3.0 to 0.4.0

    Bumps [json-schema](https://github.com/kriszyp/json-schema) from 0.3.0 to 0.4.0.
    - [Release notes](https://github.com/kriszyp/json-schema/releases)
    - [Commits](https://github.com/kriszyp/json-schema/commits)
    
    ---
    updated-dependencies:
    - dependency-name: json-schema
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 11, 2021
    Copy the full SHA
    8ec345b View commit details
  7. build(deps): bump @vue/compiler-sfc from 3.2.20 to 3.2.21

    Bumps [@vue/compiler-sfc](https://github.com/vuejs/vue-next/tree/HEAD/packages/compiler-sfc) from 3.2.20 to 3.2.21.
    - [Release notes](https://github.com/vuejs/vue-next/releases)
    - [Changelog](https://github.com/vuejs/vue-next/blob/master/CHANGELOG.md)
    - [Commits](https://github.com/vuejs/vue-next/commits/v3.2.21/packages/compiler-sfc)
    
    ---
    updated-dependencies:
    - dependency-name: "@vue/compiler-sfc"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 11, 2021
    Copy the full SHA
    1924a6f View commit details

Commits on Nov 16, 2021

  1. feature: input methods like shallow and dependecy have the same outpu…

    …t, so that mean deep dependecy also parse vue files as shallow
    anthony-redFox committed Nov 16, 2021
    Copy the full SHA
    76c7788 View commit details
  2. Copy the full SHA
    4225844 View commit details
  3. build(deps): bump @vue/compiler-sfc from 3.2.21 to 3.2.22

    Bumps [@vue/compiler-sfc](https://github.com/vuejs/vue-next/tree/HEAD/packages/compiler-sfc) from 3.2.21 to 3.2.22.
    - [Release notes](https://github.com/vuejs/vue-next/releases)
    - [Changelog](https://github.com/vuejs/vue-next/blob/master/CHANGELOG.md)
    - [Commits](https://github.com/vuejs/vue-next/commits/v3.2.22/packages/compiler-sfc)
    
    ---
    updated-dependencies:
    - dependency-name: "@vue/compiler-sfc"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 16, 2021
    Copy the full SHA
    254b3df View commit details
  4. build(deps-dev): bump lint-staged from 11.2.6 to 12.0.2

    Bumps [lint-staged](https://github.com/okonet/lint-staged) from 11.2.6 to 12.0.2.
    - [Release notes](https://github.com/okonet/lint-staged/releases)
    - [Commits](lint-staged/lint-staged@v11.2.6...v12.0.2)
    
    ---
    updated-dependencies:
    - dependency-name: lint-staged
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 16, 2021
    Copy the full SHA
    94f81ab View commit details
  5. build(deps): bump remark-reference-links from 6.0.0 to 6.0.1

    Bumps [remark-reference-links](https://github.com/remarkjs/remark-reference-links) from 6.0.0 to 6.0.1.
    - [Release notes](https://github.com/remarkjs/remark-reference-links/releases)
    - [Commits](remarkjs/remark-reference-links@6.0.0...6.0.1)
    
    ---
    updated-dependencies:
    - dependency-name: remark-reference-links
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Nov 16, 2021
    Copy the full SHA
    66ae8ad View commit details

Commits on Dec 9, 2021

  1. Copy the full SHA
    308f740 View commit details
  2. Copy the full SHA
    a31e732 View commit details

Commits on Apr 14, 2022

  1. build(deps): bump actions/setup-node from 2 to 3.1.0

    Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2 to 3.1.0.
    - [Release notes](https://github.com/actions/setup-node/releases)
    - [Commits](actions/setup-node@v2...v3.1.0)
    
    ---
    updated-dependencies:
    - dependency-name: actions/setup-node
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Apr 14, 2022
    Copy the full SHA
    9560b2c View commit details
  2. deps: update deps

    anthony-redFox committed Apr 14, 2022
    Copy the full SHA
    56cd639 View commit details
  3. build(deps): bump actions/checkout from 2 to 3

    Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and anthony-redFox committed Apr 14, 2022
    Copy the full SHA
    18aab58 View commit details
  4. Copy the full SHA
    d8ac5e9 View commit details
  5. always generate unique hash ids

    mmomtchev authored and anthony-redFox committed Apr 14, 2022
    Copy the full SHA
    4048e97 View commit details

Commits on Jul 18, 2022

  1. build(deps): bump actions/setup-node from 3.1.0 to 3.4.1

    Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.1.0 to 3.4.1.
    - [Release notes](https://github.com/actions/setup-node/releases)
    - [Commits](actions/setup-node@v3.1.0...v3.4.1)
    
    ---
    updated-dependencies:
    - dependency-name: actions/setup-node
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jul 18, 2022
    Copy the full SHA
    b182626 View commit details

Commits on Jul 31, 2022

  1. Broken External Link

    An outbound link to JSDoc was broken. updated with an active link
    sojinsamuel authored Jul 31, 2022
    Copy the full SHA
    2458ea7 View commit details

Commits on Aug 3, 2022

  1. Update lockfile to v2

    birkskyum committed Aug 3, 2022
    Copy the full SHA
    7554c93 View commit details
Showing with 23,108 additions and 10,240 deletions.
  1. +0 −35 .circleci/config.yml
  2. +15 −0 .github/dependabot.yml
  3. +30 −0 .github/workflows/node.js.yml
  4. +4 −0 .husky/pre-commit
  5. +38 −0 CHANGELOG.md
  6. +2 −3 CONTRIBUTING.md
  7. +12 −0 LICENSE
  8. +20 −27 README.md
  9. +6 −6 __tests__/__snapshots__/bin-readme.js.snap
  10. +340 −144 __tests__/__snapshots__/bin.js.snap
  11. +6 −2 __tests__/__snapshots__/index.js.snap
  12. +1,393 −575 __tests__/__snapshots__/test.js.snap
  13. +8 −5 __tests__/bin-readme.js
  14. +0 −161 __tests__/bin-watch-serve.js
  15. +31 −45 __tests__/bin.js
  16. +1 −1 __tests__/fixture/custom_theme/index.js
  17. +11 −0 __tests__/fixture/html/nested.input.js
  18. +1 −1 __tests__/fixture/sort-order-alpha.input.js
  19. +19 −18 __tests__/format_type.js
  20. +4 −4 __tests__/index.js
  21. +0 −7 __tests__/lib/__snapshots__/server.js.snap
  22. +58 −0 __tests__/lib/__snapshots__/sort.js.snap
  23. +6 −6 __tests__/lib/filter_access.js
  24. +5 −5 __tests__/lib/flow_doctrine.js
  25. +9 −5 __tests__/lib/git/find_git.js
  26. +8 −6 __tests__/lib/git/url_prefix.js
  27. +18 −16 __tests__/lib/github.js
  28. +15 −15 __tests__/lib/hierarchy.js
  29. +45 −21 __tests__/lib/infer/access.js
  30. +6 −4 __tests__/lib/infer/augments.js
  31. +6 −6 __tests__/lib/infer/finders.js
  32. +10 −6 __tests__/lib/infer/implements.js
  33. +35 −37 __tests__/lib/infer/kind.js
  34. +98 −79 __tests__/lib/infer/membership.js
  35. +27 −25 __tests__/lib/infer/name.js
  36. +26 −21 __tests__/lib/infer/params.js
  37. +9 −6 __tests__/lib/infer/properties.js
  38. +15 −8 __tests__/lib/infer/return.js
  39. +5 −5 __tests__/lib/infer/type.js
  40. +7 −7 __tests__/lib/input/dependency.js
  41. +10 −12 __tests__/lib/input/shallow.js
  42. +9 −10 __tests__/lib/lint.js
  43. +98 −89 __tests__/lib/merge_config.js
  44. +4 −11 __tests__/lib/module_filters.js
  45. +6 −6 __tests__/lib/nest.js
  46. +4 −3 __tests__/lib/output/util/formatters.js
  47. +5 −4 __tests__/lib/parse.js
  48. +4 −3 __tests__/lib/parsers/javascript.js
  49. +5 −5 __tests__/lib/parsers/parse_to_ast.js
  50. +0 −59 __tests__/lib/server.js
  51. +20 −29 __tests__/lib/sort.js
  52. +4 −3 __tests__/lib/ts_doctrine.js
  53. +4 −4 __tests__/lib/walk.js
  54. +1 −1 __tests__/linker.js
  55. +34 −39 __tests__/test.js
  56. +4 −23 __tests__/utils.js
  57. +4 −25 bin/documentation.js
  58. +1 −6 docs/NODE_API.md
  59. +4 −7 docs/USAGE.md
  60. +19,790 −0 package-lock.json
  61. +60 −75 package.json
  62. +23 −26 src/commands/build.js
  63. +4 −6 src/commands/index.js
  64. +11 −9 src/commands/lint.js
  65. +40 −49 src/commands/readme.js
  66. +0 −99 src/commands/serve.js
  67. +7 −14 src/commands/shared_options.js
  68. +29 −0 src/config.js
  69. +58 −47 src/default_theme/index.js
  70. +11 −5 src/extractors/comments.js
  71. +17 −11 src/extractors/exported.js
  72. +2 −2 src/filter_access.js
  73. +3 −2 src/flow_doctrine.js
  74. +1 −1 src/garbage_collect.js
  75. +4 −4 src/get-readme-file.js
  76. +3 −5 src/git/find_git.js
  77. +6 −9 src/git/url_prefix.js
  78. +5 −5 src/github.js
  79. +3 −3 src/hierarchy.js
  80. +40 −57 src/index.js
  81. +1 −3 src/infer/access.js
  82. +5 −5 src/infer/augments.js
  83. +2 −4 src/infer/finders.js
  84. +5 −5 src/infer/implements.js
  85. +2 −4 src/infer/kind.js
  86. +6 −6 src/infer/membership.js
  87. +3 −5 src/infer/name.js
  88. +10 −11 src/infer/params.js
  89. +3 −5 src/infer/properties.js
  90. +4 −6 src/infer/return.js
  91. +3 −5 src/infer/type.js
  92. +12 −64 src/input/dependency.js
  93. +108 −0 src/input/moduleDeps.js
  94. +42 −0 src/input/readFileCode.js
  95. +18 −20 src/input/shallow.js
  96. +4 −6 src/{ → input}/smart_glob.js
  97. +2 −2 src/is_jsdoc_comment.js
  98. +7 −10 src/lint.js
  99. +49 −61 src/merge_config.js
  100. +1 −52 src/module_filters.js
  101. +3 −6 src/nest.js
  102. +4 −4 src/output/highlighter.js
  103. +10 −20 src/output/html.js
  104. +2 −4 src/output/json.js
  105. +3 −5 src/output/markdown.js
  106. +11 −13 src/output/markdown_ast.js
  107. +4 −5 src/output/util/format_type.js
  108. +10 −9 src/output/util/formatters.js
  109. +3 −5 src/output/util/linker_stack.js
  110. +3 −3 src/output/util/reroute_links.js
  111. +3 −5 src/parse.js
  112. +12 −28 src/parsers/javascript.js
  113. +20 −14 src/parsers/parse_to_ast.js
  114. +0 −33 src/parsers/vue.js
  115. +4 −4 src/remark-jsDoc-link.js
  116. +5 −5 src/remark-parse.js
  117. +3 −3 src/remark-remove-position.js
  118. +0 −40 src/serve/error_page.js
  119. +0 −118 src/serve/server.js
  120. +25 −14 src/sort.js
  121. +3 −2 src/ts_doctrine.js
  122. +4 −4 src/type_annotation.js
  123. +2 −2 src/walk.js
  124. +0 −7,540 yarn.lock
35 changes: 0 additions & 35 deletions .circleci/config.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.4.1
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test-ci
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run pre-commit
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,44 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [14.0.0](https://github.com/documentationjs/documentation/compare/v14.0.0-alpha.1...v14.0.0) (2022-08-19)

## [14.0.0-alpha.1](https://github.com/documentationjs/documentation/compare/v14.0.0-alpha.0...v14.0.0-alpha.1) (2022-08-07)


### Features

* :sparkles: update Babel, copy list of plugins from Prettier ([3f187d7](https://github.com/documentationjs/documentation/commit/3f187d73132c6667a9140bd491c5f703c1f37c40))

## [14.0.0-alpha.0](https://github.com/documentationjs/documentation/compare/v13.2.5...v14.0.0-alpha.0) (2022-08-05)


### ⚠ BREAKING CHANGES

* all Extensions whould contains '.' so that mean if you have just 'ts' then need to convert to '.ts'
* external parameter was removed
Migration plan propose to move all external resources to input usages
Motivation: packages has many inputs which describe in package.json
so that mean need each time to parse all package.json of exsternal resources to understand which etry point need to pick.
But it is base on guesses because entry point may could not contains a documentation and the best way to handle it manualy.
* The serve parametr was remove, you can use any other tools which could be refresh and store your html site
The private parameter has removed, use a access
* documentation.js will now require node 14 or later.

### Bug Fixes

* add micromark dependencies fixed [#1381](https://github.com/documentationjs/documentation/issues/1381) ([3ba8165](https://github.com/documentationjs/documentation/commit/3ba81659d7db5d9393fa083287d91db93d6aab5e))
* add TS and TSX as default extensions fixed [#1377](https://github.com/documentationjs/documentation/issues/1377) ([f0cb1c0](https://github.com/documentationjs/documentation/commit/f0cb1c0bb1d97228c7baab453e50e5dbe283ea46))
* external was removed as prefer of input usages ([e3c59d7](https://github.com/documentationjs/documentation/commit/e3c59d77e4e3cf6e5fabab7c0d853a06a77f6288))
* html report, it is return html if output is not defined ([0975871](https://github.com/documentationjs/documentation/commit/0975871b34b8cc0af74e0aebb43f2727e0ab9960))
* remove private parameter, use access (BREAKING CHANGES) ([874069c](https://github.com/documentationjs/documentation/commit/874069c0b3647dad413667f61d05f6d39992995d))
* The server parameter deprecated and will be remove in next Major version fixed [#1413](https://github.com/documentationjs/documentation/issues/1413) ([810e08b](https://github.com/documentationjs/documentation/commit/810e08b6fdb1076a1758bff831a9f42890f0f25f))
* use process.cwd vs `.` which can fail ([4cc70a5](https://github.com/documentationjs/documentation/commit/4cc70a5aed0c233cdcc72077733f9da8450be386))


* replace module-deps-sortable on own implementation to control how parse files ([abb781a](https://github.com/documentationjs/documentation/commit/abb781a69ac69423da11346f62d7064382bb7b74))
* Update Node minimum version to 14 ([fc0bb3c](https://github.com/documentationjs/documentation/commit/fc0bb3cd885b9577e6f1f6935e15d4ec24f89114))

### [13.2.5](https://github.com/documentationjs/documentation/compare/v13.2.4...v13.2.5) (2021-04-24)


5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -38,8 +38,7 @@ before merge.
Release process:

* Confirm that `master` passes CI tests
* Bump version in `package.json`
* Run `npm run changelog`
* Add updated CHANGELOG.md to master
* Run `npm run release` or in case it's a prerelease you'd run i.e. `npm run release -- --prerelease alpha`
* It will automatically update teh version in package.json and make a git tag.
* Push commits
* npm publish
12 changes: 12 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -38,3 +38,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------------------

Contains sections of prettier

Copyright © James Long and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 changes: 20 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,28 +14,28 @@

[:date: Current maintenance status](https://github.com/documentationjs/documentation/wiki/Current-maintenance-status)

* Supports modern JavaScript: ES5, ES2017, JSX, Vue and [Flow](https://flow.org/) type annotations.
* Infers parameters, types, membership, and more. Write less documentation: let the computer write it for you.
* Integrates with GitHub to link directly from documentation to the code it refers to.
* Customizable output: HTML, JSON, Markdown, and more
- Supports modern JavaScript: ES5, ES2017, JSX, Vue and [Flow](https://flow.org/) type annotations.
- Infers parameters, types, membership, and more. Write less documentation: let the computer write it for you.
- Integrates with GitHub to link directly from documentation to the code it refers to.
- Customizable output: HTML, JSON, Markdown, and more

## Examples

- [HTML output with default template](https://documentation.js.org/html-example/)
- [Markdown](https://github.com/documentationjs/documentation/blob/master/docs/NODE_API.md)
- [JSON](https://documentation.js.org/html-example/index.json)
- [HTML output with default template](https://documentation.js.org/html-example/)
- [Markdown](https://github.com/documentationjs/documentation/blob/master/docs/NODE_API.md)
- [JSON](https://documentation.js.org/html-example/index.json)

## Documentation

- [Getting Started](docs/GETTING_STARTED.md): start here
- [Usage](docs/USAGE.md): how to use documentation.js
- [Recipes](docs/RECIPES.md): tricks for writing effective JSDoc docs
- [Node API](docs/NODE_API.md): documentation.js's self-generated documentation
- [Configuring documentation.js](docs/CONFIG.md)
- [FAQ](docs/FAQ.md)
- [Troubleshooting](docs/TROUBLESHOOTING.md)
- [Theming](docs/THEMING.md): tips for theming documentation output in HTML
- [See also](https://github.com/documentationjs/documentation/wiki/See-also): a list of projects similar to documentation.js
- [Getting Started](docs/GETTING_STARTED.md): start here
- [Usage](docs/USAGE.md): how to use documentation.js
- [Recipes](docs/RECIPES.md): tricks for writing effective JSDoc docs
- [Node API](docs/NODE_API.md): documentation.js's self-generated documentation
- [Configuring documentation.js](docs/CONFIG.md)
- [FAQ](docs/FAQ.md)
- [Troubleshooting](docs/TROUBLESHOOTING.md)
- [Theming](docs/THEMING.md): tips for theming documentation output in HTML
- [See also](https://github.com/documentationjs/documentation/wiki/See-also): a list of projects similar to documentation.js

## User Guide

@@ -46,7 +46,7 @@ $ npm install -g documentation
```

This installs a command called `documentation` in your path, that you can
point at [JSDoc](http://usejsdoc.org/)-annotated source code to generate
point at [JSDoc](https://jsdoc.app/about-getting-started.html)-annotated source code to generate
human-readable documentation. First, run `documentation` with the `--help`
option for help:

@@ -62,12 +62,6 @@ documentation build src/** -f html --github -o docs
# document index.js, ignoring any files it requires or imports
documentation build index.js -f md --shallow

# build and serve HTML docs for app.js
documentation serve app.js

# build, serve, and live-update HTML docs for app.js
documentation serve --watch app.js

# validate JSDoc syntax in util.js
documentation lint util.js

@@ -81,7 +75,6 @@ documentation build --document-exported index.js
documentation build index.ts --parse-extension ts -f html -o docs

Commands:
serve [input..] generate, update, and display HTML documentation
build [input..] build documentation
lint [input..] check for common style and uniformity mistakes
readme [input..] inject documentation into your README.md
@@ -97,9 +90,9 @@ _We have plenty of
[issues](https://github.com/documentationjs/documentation/issues) that we'd
love help with._

- Robust and complete `JSDoc` support, including typedefs.
- Strong support for HTML and Markdown output
- Documentation coverage, statistics, and validation
- Robust and complete `JSDoc` support, including typedefs.
- Strong support for HTML and Markdown output
- Documentation coverage, statistics, and validation

documentation is an OPEN Open Source Project. This means that:

12 changes: 6 additions & 6 deletions __tests__/__snapshots__/bin-readme.js.snap
Original file line number Diff line number Diff line change
@@ -22,15 +22,15 @@ A function with documentation.
* \`a\` {string} blah
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** answer
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\\\_Objects/Number)** answer
## bar
A second function with docs
### Parameters
* \`b\`
* \`b\` &#x20;
# Another section
"
@@ -58,15 +58,15 @@ A function with documentation.
* \`a\` {string} blah
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** answer
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\\\_Objects/Number)** answer
## bar
A second function with docs
### Parameters
* \`b\`
* \`b\` &#x20;
# Another section
"
@@ -94,15 +94,15 @@ A function with documentation.
* \`a\` {string} blah
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** answer
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\\\_Objects/Number)** answer
## bar
A second function with docs
### Parameters
* \`b\`
* \`b\` &#x20;
# Another section
"
484 changes: 340 additions & 144 deletions __tests__/__snapshots__/bin.js.snap

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
@@ -24,12 +24,14 @@ Array [
"loc": SourceLocation {
"end": Position {
"column": 9,
"index": 9,
"line": 1,
},
"filename": undefined,
"identifierName": undefined,
"start": Position {
"column": 0,
"index": 0,
"line": 1,
},
},
@@ -90,11 +92,13 @@ exports[`build 3`] = `
\\"loc\\": {
\\"start\\": {
\\"line\\": 1,
\\"column\\": 0
\\"column\\": 0,
\\"index\\": 0
},
\\"end\\": {
\\"line\\": 1,
\\"column\\": 9
\\"column\\": 9,
\\"index\\": 9
}
},
\\"augments\\": [],
1,968 changes: 1,393 additions & 575 deletions __tests__/__snapshots__/test.js.snap

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions __tests__/bin-readme.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const path = require('path');
const os = require('os');
const exec = require('child_process').exec;
const tmp = require('tmp');
const fs = require('fs-extra');
import path from 'path';
import { exec } from 'child_process';
import tmp from 'tmp';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function documentation(args, options, parseJSON) {
return new Promise((resolve, reject) => {
161 changes: 0 additions & 161 deletions __tests__/bin-watch-serve.js

This file was deleted.

76 changes: 31 additions & 45 deletions __tests__/bin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* global jasmine */

const path = require('path');
const os = require('os');
const exec = require('child_process').exec;
const tmp = require('tmp');
const fs = require('fs-extra');
import path from 'path';
import os from 'os';
import { exec } from 'child_process';
import tmp from 'tmp';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function documentation(args, options, parseJSON) {
if (!options) {
@@ -46,7 +48,7 @@ function normalize(result) {
return result;
}

test.skip('documentation binary', async function () {
test('documentation binary', async function () {
const data = await documentation(['build fixture/simple.input.js'], {});
expect(data.length).toBe(1);
});
@@ -58,14 +60,14 @@ test.skip('defaults to parsing package.json main', async function () {
expect(data.length).toBeTruthy();
});

test.skip('accepts config file', async function () {
test('accepts config file', async function () {
const data = await documentation([
'build fixture/sorting/input.js -c fixture/config.json'
]);
expect(normalize(data)).toMatchSnapshot();
});

test.skip('accepts config file - reports failures', async function () {
test('accepts config file - reports failures', async function () {
try {
await documentation(
['build fixture/sorting/input.js -c fixture/config-bad.yml'],
@@ -77,7 +79,7 @@ test.skip('accepts config file - reports failures', async function () {
}
});

test.skip('accepts config file - reports parse failures', async function () {
test('accepts config file - reports parse failures', async function () {
try {
await documentation(
['build fixture/sorting/input.js -c fixture/config-malformed.json'],
@@ -89,42 +91,34 @@ test.skip('accepts config file - reports parse failures', async function () {
}
});

test.skip('--shallow option', async function () {
test('--shallow option', async function () {
const data = await documentation([
'build --shallow fixture/internal.input.js'
]);
expect(data.length).toBe(0);
});

test.skip('external modules option', async function () {
const data = await documentation([
'build fixture/external.input.js ' +
'--external=external --external=external/node_modules'
]);
expect(data.length).toBe(2);
});

test.skip('when a file is specified both in a glob and explicitly, it is only documented once', async function () {
test('when a file is specified both in a glob and explicitly, it is only documented once', async function () {
const data = await documentation([
'build fixture/simple.input.js fixture/simple.input.*'
]);
expect(data.length).toBe(1);
});

test.skip('extension option', async function () {
test('extension option', async function () {
const data = await documentation([
'build fixture/extension/index.otherextension ' +
'--requireExtension=otherextension --parseExtension=otherextension'
]);
expect(data.length).toBe(1);
});

test.skip('extension option', function () {
test('extension option', function () {
return documentation(['build fixture/extension.jsx']);
});

describe('invalid arguments', function () {
test.skip('bad -f option', async function () {
test('bad -f option', async function () {
try {
await documentation(
['build -f DOES-NOT-EXIST fixture/internal.input.js'],
@@ -136,7 +130,7 @@ describe('invalid arguments', function () {
}
});

test.skip('html with no destination', async function () {
test('html with no destination', async function () {
try {
await documentation(['build -f html fixture/internal.input.js']);
} catch (err) {
@@ -150,7 +144,7 @@ describe('invalid arguments', function () {
}
});

test.skip('bad command', async function () {
test('bad command', async function () {
try {
await documentation(['-f html fixture/internal.input.js'], {}, false);
} catch (err) {
@@ -159,8 +153,9 @@ describe('invalid arguments', function () {
});
});

const semver = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
test.skip('--config', async function () {
const semver =
/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
test('--config', async function () {
const dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
fs.mkdirSync(dst);
const outputIndex = path.join(dst, 'index.html');
@@ -173,18 +168,18 @@ test.skip('--config', async function () {
false
);
let output = fs.readFileSync(outputIndex, 'utf8');
const version = require('../package.json').version;
const version = (await import('../package.json')).default.version;
output = output.replace(new RegExp(version.replace(/\./g, '\\.'), 'g'), '');
expect(output).toMatchSnapshot();
});

test.skip('--version', async function () {
test('--version', async function () {
const output = await documentation(['--version'], {}, false);
expect(output).toBeTruthy();
});

describe('lint command', function () {
test.skip('generates lint output', async function () {
test('generates lint output', async function () {
try {
await documentation(['lint fixture/lint/lint.input.js'], {}, false);
} catch (err) {
@@ -193,7 +188,7 @@ describe('lint command', function () {
}
});

test.skip('generates no output on a good file', async function () {
test('generates no output on a good file', async function () {
const data = await documentation(
['lint fixture/simple.input.js'],
{},
@@ -202,7 +197,7 @@ describe('lint command', function () {
expect(data).toBe('');
});

test.skip('exposes syntax error on a bad file', async function () {
test('exposes syntax error on a bad file', async function () {
try {
await documentation(
['lint fixture/bad/syntax.input', '--parseExtension input'],
@@ -214,7 +209,7 @@ describe('lint command', function () {
}
});

test.skip('lint with no inputs', async function () {
test('lint with no inputs', async function () {
try {
await documentation(
['lint'],
@@ -228,7 +223,7 @@ describe('lint command', function () {
}
});

test.skip('generates lint output with shallow', async function () {
test('generates lint output with shallow', async function () {
const data = await documentation(
['lint fixture/lint/lint.input.shallow.js --shallow'],
{},
@@ -238,7 +233,7 @@ describe('lint command', function () {
});
});

test.skip('given no files', async function () {
test('given no files', async function () {
try {
await documentation(['build']);
} catch (err) {
@@ -252,7 +247,7 @@ test.skip('given no files', async function () {
}
});

test.skip('with an invalid command', async function () {
test('with an invalid command', async function () {
try {
await documentation(['invalid'], {}, false);
} catch (err) {
@@ -269,15 +264,6 @@ test.skip('--access flag', async function () {
expect(data).toBe('[]');
});

test.skip('--private flag', async function () {
const data = await documentation(
['build fixture/internal.input.js --private'],
{},
false
);
expect(data.length > 2).toBeTruthy();
});

test.skip('--infer-private flag', async function () {
const data = await documentation(
['build fixture/infer-private.input.js --infer-private ^_'],
2 changes: 1 addition & 1 deletion __tests__/fixture/custom_theme/index.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ module.exports = function(comments, options, callback) {
new File({
base: '/',
path: '/index.html',
contents: new Buffer('Hello world')
contents: Buffer.from('Hello world')
})
]);
};
11 changes: 11 additions & 0 deletions __tests__/fixture/html/nested.input.js
Original file line number Diff line number Diff line change
@@ -145,6 +145,17 @@ class Foo {
get bar() {}
}

/**
* This is Foobar
* must have a distinct id from Foo.bar
*/
class Foobar {
/**
* This is bar
*/
get bar() { }
}

/**
* I am the container of stream types
*/
2 changes: 1 addition & 1 deletion __tests__/fixture/sort-order-alpha.input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Options: {"sortOrder": "alpha"}
// Options: {"sortOrder": ["alpha"]}

/** */
function b() {}
37 changes: 19 additions & 18 deletions __tests__/format_type.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*eslint max-len: 0 */

const _formatType = require('../src/output/util/format_type');
const LinkerStack = require('../src/output/util/linker_stack');
const remark = require('remark');
const parse = require('doctrine-temporary-fork').parse;
import _formatType from '../src/output/util/format_type.js';
import LinkerStack from '../src/output/util/linker_stack';
import { remark } from 'remark';
import doctrine from 'doctrine-temporary-fork';
const parse = doctrine.parse;

function stringify(children) {
return remark().stringify({
@@ -23,63 +24,63 @@ test('formatType', function () {
['namedType.typeProperty', 'namedType.typeProperty'],
[
'Array|undefined',
'([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))'
'([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Array) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/undefined))'
],
[
'Array<number>',
'[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>'
'[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)>'
],
[
'number!',
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)!'
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)!'
],
["('pre'|'post')", '(`"pre"` | `"post"`)'],
["'pre'|'post'", '(`"pre"` | `"post"`)'],
[
'function(string, boolean)',
'function ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))'
'function ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/String), [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Boolean))'
],
[
'function(string, boolean): number',
'function ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)): [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)'
'function ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/String), [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Boolean)): [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)'
],
['function()', 'function ()'],
[
'function(this:something, string)',
'function (this: something, [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))'
'function (this: something, [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/String))'
],
['function(new:something)', 'function (new: something)'],
[
'{myNum: number, myObject}',
'{myNum: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), myObject}'
'{myNum: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number), myObject}'
],
[
'[string,]',
'\\[[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)]'
'\\[[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/String)]'
],
[
'number?',
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?'
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)?'
],
[
'number',
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)'
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)'
],
['?', '?'],
['void', 'void'],
['function(a:b)', 'function (a: b)'],
['function(a):void', 'function (a): void'],
[
'number=',
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?'
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)?'
],
[
'...number',
'...[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)'
'...[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)'
],
[
'undefined',
'[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)'
'[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/undefined)'
]
].forEach(function (example) {
expect(
@@ -96,7 +97,7 @@ test('formatType', function () {
formatType(parse('@param {number} [a=1]', { sloppy: true }).tags[0].type)
)
).toEqual(
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?\n'
'[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global\\_Objects/Number)?\n'
);

expect(
8 changes: 4 additions & 4 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const documentation = require('../src/');
const os = require('os');
const path = require('path');
const fs = require('fs');
import * as documentation from '../src/index.js';
import os from 'os';
import path from 'path';
import fs from 'fs';

function inputs(contents) {
const dirEntry = os.tmpdir();
7 changes: 0 additions & 7 deletions __tests__/lib/__snapshots__/server.js.snap

This file was deleted.

58 changes: 58 additions & 0 deletions __tests__/lib/__snapshots__/sort.js.snap
Original file line number Diff line number Diff line change
@@ -38,12 +38,26 @@ Array [
"sortKey": "b",
},
"name": "carrot",
"path": Array [
Object {
"name": "carrot",
"scope": "static",
"toc": true,
},
],
},
Object {
"context": Object {
"sortKey": "c",
},
"name": "bananas",
"path": Array [
Object {
"name": "bananas",
"scope": "static",
"toc": true,
},
],
},
]
`;
@@ -86,12 +100,26 @@ Array [
"sortKey": "b",
},
"name": "carrot",
"path": Array [
Object {
"name": "carrot",
"scope": "static",
"toc": true,
},
],
},
Object {
"context": Object {
"sortKey": "c",
},
"name": "bananas",
"path": Array [
Object {
"name": "bananas",
"scope": "static",
"toc": true,
},
],
},
]
`;
@@ -102,13 +130,15 @@ Array [
"context": Object {
"sortKey": "a",
},
"kind": "function",
"memberof": "classB",
"name": "apples",
},
Object {
"context": Object {
"sortKey": "c",
},
"kind": "function",
"memberof": "classB",
"name": "bananas",
},
@@ -121,3 +151,31 @@ Array [
},
]
`;

exports[`sort toc with files absolute path 3`] = `
Array [
Object {
"context": Object {
"sortKey": "b",
},
"memberof": "classB",
"name": "carrot",
},
Object {
"context": Object {
"sortKey": "a",
},
"kind": "function",
"memberof": "classB",
"name": "apples",
},
Object {
"context": Object {
"sortKey": "c",
},
"kind": "function",
"memberof": "classB",
"name": "bananas",
},
]
`;
12 changes: 6 additions & 6 deletions __tests__/lib/filter_access.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const filterAccess = require('../../src/filter_access');
import filterAccess from '../../src/filter_access.js';

test('filterAccess ignore', function() {
test('filterAccess ignore', function () {
expect(
filterAccess(
['public', 'protected', 'undefined'],
@@ -14,7 +14,7 @@ test('filterAccess ignore', function() {
).toEqual([]);
});

test('filterAccess public, protected, undefined, no private', function() {
test('filterAccess public, protected, undefined, no private', function () {
expect(
filterAccess(
['public', 'protected', 'undefined'],
@@ -46,7 +46,7 @@ test('filterAccess public, protected, undefined, no private', function() {
]);
});

test('filterAccess explicit public', function() {
test('filterAccess explicit public', function () {
expect(
filterAccess(
['public'],
@@ -64,7 +64,7 @@ test('filterAccess explicit public', function() {
]);
});

test('filterAccess override', function() {
test('filterAccess override', function () {
expect(
filterAccess(
['private'],
@@ -81,7 +81,7 @@ test('filterAccess override', function() {
]);
});

test('filterAccess nesting', function() {
test('filterAccess nesting', function () {
expect(
filterAccess(
['public', 'protected', 'undefined'],
10 changes: 5 additions & 5 deletions __tests__/lib/flow_doctrine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const flowDoctrine = require('../../src/flow_doctrine.js');
const parse = require('../../src/parsers/javascript');
const FLOW_TYPES = require('@babel/types').FLOW_TYPES;
import flowDoctrine from '../../src/flow_doctrine.js';
import parse from '../../src/parsers/javascript';
import { FLOW_TYPES } from '@babel/types';

function toComment(fn, filename) {
return parse(
@@ -12,8 +12,8 @@ function toComment(fn, filename) {
)[0];
}

test('flowDoctrine', function() {
const types = FLOW_TYPES.filter(function(type) {
test('flowDoctrine', function () {
const types = FLOW_TYPES.filter(function (type) {
return type.match(/\wTypeAnnotation$/);
});

14 changes: 9 additions & 5 deletions __tests__/lib/git/find_git.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const mock = require('mock-fs');
const mockRepo = require('../../utils').mockRepo;
const path = require('path');
const findGit = require('../../../src/git/find_git');
import mock from 'mock-fs';
import { mockRepo } from '../../utils.js';
import path from 'path';
import findGit from '../../../src/git/find_git.js';
import { fileURLToPath } from 'url';

test('findGit', function() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

test('findGit', function () {
mock(mockRepo.master);
const root =
path.parse(__dirname).root + path.join('my', 'repository', 'path');
14 changes: 8 additions & 6 deletions __tests__/lib/git/url_prefix.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const mock = require('mock-fs');
const mockRepo = require('../../utils').mockRepo;
const getGithubURLPrefix = require('../../../src/git/url_prefix');
const parsePackedRefs = getGithubURLPrefix.parsePackedRefs;
import mock from 'mock-fs';
import { mockRepo } from '../../utils.js';
import {
getGithubURLPrefix,
parsePackedRefs
} from '../../../src/git/url_prefix.js';

test('getGithubURLPrefix', function() {
test('getGithubURLPrefix', function () {
mock(mockRepo.master);
const masterUrl = getGithubURLPrefix({
git: '/my/repository/path/.git',
@@ -34,7 +36,7 @@ test('getGithubURLPrefix', function() {
expect(submoduleUrl).toBe('https://github.com/foo/bar/blob/this_is_the_sha/');
});

test('parsePackedRefs', function() {
test('parsePackedRefs', function () {
const input =
'# pack-refs with: peeled fully-peeled\n' +
'4acd658617928bd17ae7364ef2512630d97c007a refs/heads/babel-6\n' +
34 changes: 18 additions & 16 deletions __tests__/lib/github.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint no-unused-vars: 0 */
import mock from 'mock-fs';
import path from 'path';
import { mockRepo } from '../utils.js';
import parse from '../../src/parsers/javascript.js';
import github from '../../src/github.js';
import { fileURLToPath } from 'url';

const mock = require('mock-fs');
const path = require('path');
const mockRepo = require('../utils').mockRepo;
const parse = require('../../src/parsers/javascript');
const github = require('../../src/github');
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// mock-fs is causing some unusual side effects with jest-resolve
// not being able to resolve modules so we've disabled these tests
@@ -29,15 +32,15 @@ function evaluate(fn) {
);
}

afterEach(function() {
afterEach(function () {
mock.restore();
});

test.skip('github', function() {
test.skip('github', function () {
mock(mockRepo.master);

expect(
evaluate(function() {
evaluate(function () {
/**
* get one
* @returns {number} one
@@ -52,11 +55,11 @@ test.skip('github', function() {
});
});

test.skip('malformed repository', function() {
test.skip('malformed repository', function () {
mock(mockRepo.malformed);

expect(
evaluate(function() {
evaluate(function () {
/**
* get one
* @returns {number} one
@@ -68,11 +71,11 @@ test.skip('malformed repository', function() {
).toBe(undefined);
});

test.skip('enterprise repository', function() {
test.skip('enterprise repository', function () {
mock(mockRepo.enterprise);

expect(
evaluate(function() {
evaluate(function () {
/**
* get one
* @returns {number} one
@@ -83,16 +86,15 @@ test.skip('enterprise repository', function() {
})[0].context.github
).toEqual({
path: 'index.js',
url:
'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
url: 'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
});
});

test.skip('typedef', function() {
test.skip('typedef', function () {
mock(mockRepo.master);

expect(
evaluate(function() {
evaluate(function () {
/**
* A number, or a string containing a number.
* @typedef {(number|string)} NumberLike
30 changes: 15 additions & 15 deletions __tests__/lib/hierarchy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const parse = require('../../src/parsers/javascript');
const hierarchy = require('../../src/hierarchy');
import parse from '../../src/parsers/javascript.js';
import hierarchy from '../../src/hierarchy.js';

function toComments(fn, filename) {
return parse(
@@ -16,13 +16,13 @@ function evaluate(fn, callback) {
}

function map(arr, prop) {
return arr.map(function(item) {
return arr.map(function (item) {
return item[prop];
});
}

test('hierarchy', function() {
const comments = evaluate(function() {
test('hierarchy', function () {
const comments = evaluate(function () {
/**
* @name Class
* @class
@@ -66,8 +66,8 @@ test('hierarchy', function() {
expect(map(classMembers.events[0].path, 'name')).toEqual(['Class', 'event']);
});

test('hierarchy - nesting', function() {
const comments = evaluate(function() {
test('hierarchy - nesting', function () {
const comments = evaluate(function () {
/**
* @name Parent
* @class
@@ -105,8 +105,8 @@ test('hierarchy - nesting', function() {
]);
});

test('hierarchy - multisignature', function() {
const comments = evaluate(function() {
test('hierarchy - multisignature', function () {
const comments = evaluate(function () {
/**
* @name Parent
* @class
@@ -126,8 +126,8 @@ test('hierarchy - multisignature', function() {
expect(map(comments[0].members.instance, 'name')).toEqual(['foo', 'foo']);
});

test('hierarchy - missing memberof', function() {
const test = evaluate(function() {
test('hierarchy - missing memberof', function () {
const test = evaluate(function () {
/**
* @name test
* @memberof DoesNotExist
@@ -142,8 +142,8 @@ test('hierarchy - missing memberof', function() {
]);
});

test('hierarchy - anonymous', function() {
const result = evaluate(function() {
test('hierarchy - anonymous', function () {
const result = evaluate(function () {
/** Test */
})[0];

@@ -154,8 +154,8 @@ test('hierarchy - anonymous', function() {
]);
});

test('hierarchy - object prototype member names', function() {
const comments = evaluate(function() {
test('hierarchy - object prototype member names', function () {
const comments = evaluate(function () {
/**
* @name should
* @function
66 changes: 45 additions & 21 deletions __tests__/lib/infer/access.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const parse = require('../../../src/parsers/javascript');
const inferName = require('../../../src/infer/name');
const inferAccess = require('../../../src/infer/access');
import parse from '../../../src/parsers/javascript.js';
import inferName from '../../../src/infer/name.js';
import inferAccess from '../../../src/infer/access.js';

function toComment(fn, filename) {
return parse(
@@ -16,86 +16,110 @@ function evaluate(fn, re, filename) {
return inferAccess(re)(inferName(toComment(fn, filename)));
}

test('inferAccess', function() {
test('inferAccess', function () {
expect(
evaluate(function() {
evaluate(function () {
/** Test */
function _name() {}
}, '^_').access
).toBe('private');

expect(
evaluate(function() {
evaluate(function () {
/** @private */
function name() {}
}, '^_').access
).toBe('private');

expect(
evaluate(function() {
evaluate(function () {
/** @public */
function _name() {}
}, '^_').access
).toBe('public');

expect(
evaluate(function() {
evaluate(function () {
/** Test */
function name_() {}
}, '_$').access
).toBe('private');

expect(
evaluate(`
evaluate(
`
class Test {
/** */
private foo() {}
}
`, '_$', 'test.ts').access
`,
'_$',
'test.ts'
).access
).toBe('private');

expect(
evaluate(`
evaluate(
`
class Test {
/** */
protected foo() {}
}
`, '_$', 'test.ts').access
`,
'_$',
'test.ts'
).access
).toBe('protected');

expect(
evaluate(`
evaluate(
`
class Test {
/** */
public foo() {}
}
`, '_$', 'test.ts').access
`,
'_$',
'test.ts'
).access
).toBe('public');

expect(
evaluate(`
class Test {
evaluate(
`
abstract class Test {
/** */
public abstract foo();
}
`, '_$', 'test.ts').access
`,
'_$',
'test.ts'
).access
).toBe('public');

expect(
evaluate(`
evaluate(
`
class Test {
/** */
readonly name: string;
}
`, '_$', 'test.ts').readonly
`,
'_$',
'test.ts'
).readonly
).toBe(true);

expect(
evaluate(`
evaluate(
`
interface Test {
/** */
readonly name: string;
}
`, '_$', 'test.ts').readonly
`,
'_$',
'test.ts'
).readonly
).toBe(true);
});
10 changes: 6 additions & 4 deletions __tests__/lib/infer/augments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-disable no-unused-vars*/
const inferAugments = require('../../../src/infer/augments');
const parse = require('../../../src/parsers/javascript');
import inferAugments from '../../../src/infer/augments';
import parse from '../../../src/parsers/javascript';

function toComment(fn, filename) {
return parse(
@@ -16,7 +16,7 @@ function evaluate(code, filename) {
return inferAugments(toComment(code, filename));
}

test('inferAugments', function() {
test('inferAugments', function () {
expect(evaluate('/** */class A extends B {}').augments).toEqual([
{
name: 'B',
@@ -35,7 +35,9 @@ test('inferAugments', function() {
}
]);

expect(evaluate('/** */interface A extends B, C {}', 'test.ts').augments).toEqual([
expect(
evaluate('/** */interface A extends B, C {}', 'test.ts').augments
).toEqual([
{
name: 'B',
title: 'extends'
12 changes: 6 additions & 6 deletions __tests__/lib/infer/finders.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const parse = require('../../../src/parsers/javascript');
const findTarget = require('../../../src/infer/finders').findTarget;
import parse from '../../../src/parsers/javascript.js';
import findTarget from '../../../src/infer/finders';

function toComment(fn) {
if (typeof fn == 'function') {
@@ -18,10 +18,10 @@ function evaluate(fn, re) {
return toComment(fn);
}

test('findTarget', function() {
test('findTarget', function () {
expect(
findTarget(
toComment(function() {
toComment(function () {
/** Test */
const x = 10;
}).context.ast
@@ -30,7 +30,7 @@ test('findTarget', function() {

expect(
findTarget(
toComment(function() {
toComment(function () {
const z = {};

/** Test */
@@ -41,7 +41,7 @@ test('findTarget', function() {

expect(
findTarget(
toComment(function() {
toComment(function () {
const z = {
/** Test */
y: 10
16 changes: 10 additions & 6 deletions __tests__/lib/infer/implements.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-disable no-unused-vars*/
const inferImplements = require('../../../src/infer/implements');
const parse = require('../../../src/parsers/javascript');
import inferImplements from '../../../src/infer/implements';
import parse from '../../../src/parsers/javascript';

function toComment(fn, filename) {
return parse(
@@ -16,7 +16,7 @@ function evaluate(code, filename) {
return inferImplements(toComment(code, filename));
}

test('inferImplements (flow)', function() {
test('inferImplements (flow)', function () {
expect(evaluate('/** */class A implements B {}').implements).toEqual([
{
name: 'B',
@@ -36,15 +36,19 @@ test('inferImplements (flow)', function() {
]);
});

test('inferImplements (typescript)', function() {
expect(evaluate('/** */class A implements B {}', 'test.ts').implements).toEqual([
test('inferImplements (typescript)', function () {
expect(
evaluate('/** */class A implements B {}', 'test.ts').implements
).toEqual([
{
name: 'B',
title: 'implements'
}
]);

expect(evaluate('/** */class A implements B, C {}', 'test.ts').implements).toEqual([
expect(
evaluate('/** */class A implements B, C {}', 'test.ts').implements
).toEqual([
{
name: 'B',
title: 'implements'
72 changes: 35 additions & 37 deletions __tests__/lib/infer/kind.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-disable no-unused-vars*/
const inferKind = require('../../../src/infer/kind');
const parse = require('../../../src/parsers/javascript');
import inferKind from '../../../src/infer/kind';
import parse from '../../../src/parsers/javascript';

function toComment(fn, filename) {
return parse(
@@ -12,7 +12,7 @@ function toComment(fn, filename) {
)[0];
}

test('inferKind', function() {
test('inferKind', function () {
expect(
inferKind({
kind: 'class',
@@ -38,13 +38,15 @@ test('inferKind', function() {
).kind
).toBe('class');

const abstractClass = inferKind(toComment('/** */ abstract class C {}', 'test.ts'));
const abstractClass = inferKind(
toComment('/** */ abstract class C {}', 'test.ts')
);
expect(abstractClass.kind).toBe('class');
expect(abstractClass.abstract).toBe(true);

expect(
inferKind(
toComment(function() {
toComment(function () {
/** function */
function foo() {}
foo();
@@ -54,9 +56,9 @@ test('inferKind', function() {

expect(
inferKind(
toComment(function() {
toComment(function () {
/** function */
const foo = function() {};
const foo = function () {};
foo();
})
).kind
@@ -68,8 +70,9 @@ test('inferKind', function() {
).toBe('interface');

expect(
inferKind(toComment('/** Exported interface */' + 'interface myinter {}', 'test.ts'))
.kind
inferKind(
toComment('/** Exported interface */' + 'interface myinter {}', 'test.ts')
).kind
).toBe('interface');

expect(
@@ -133,25 +136,29 @@ test('inferKind', function() {
expect(generatorMethod.kind).toBe('function');
expect(generatorMethod.generator).toBe(true);

const abstractMethod = inferKind(toComment('abstract class C { /** */ abstract foo(); }', 'test.ts'));
const abstractMethod = inferKind(
toComment('abstract class C { /** */ abstract foo(); }', 'test.ts')
);
expect(abstractMethod.kind).toBe('function');
expect(abstractMethod.abstract).toBe(true);

expect(inferKind(toComment('interface Foo { /** b */ b(v): void; }')).kind).toBe(
'function'
);
expect(
inferKind(toComment('interface Foo { /** b */ b(v): void; }')).kind
).toBe('function');

expect(inferKind(toComment('interface Foo { /** b */ b: string; }')).kind).toBe(
'member'
);
expect(
inferKind(toComment('interface Foo { /** b */ b: string; }')).kind
).toBe('member');

expect(inferKind(toComment('interface Foo { /** b */ b(v): void; }', 'test.ts')).kind).toBe(
'function'
);
expect(
inferKind(toComment('interface Foo { /** b */ b(v): void; }', 'test.ts'))
.kind
).toBe('function');

expect(inferKind(toComment('interface Foo { /** b */ b: string; }', 'test.ts')).kind).toBe(
'member'
);
expect(
inferKind(toComment('interface Foo { /** b */ b: string; }', 'test.ts'))
.kind
).toBe('member');

expect(inferKind(toComment('/** */ enum Foo { A }', 'test.ts')).kind).toBe(
'enum'
@@ -163,7 +170,7 @@ test('inferKind', function() {

expect(
inferKind(
toComment(function() {
toComment(function () {
/** class */
function Foo() {}
})
@@ -172,7 +179,7 @@ test('inferKind', function() {

expect(
inferKind(
toComment(function() {
toComment(function () {
/** undefined */
})
).kind
@@ -197,21 +204,12 @@ test('inferKind', function() {
).kind
).toBe('constant');

expect(
inferKind(
toComment(
'/** */' + 'type Foo = string'
)
).kind
).toBe('typedef');
expect(inferKind(toComment('/** */' + 'type Foo = string')).kind).toBe(
'typedef'
);

expect(
inferKind(
toComment(
'/** */' + 'type Foo = string',
'test.ts'
)
).kind
inferKind(toComment('/** */' + 'type Foo = string', 'test.ts')).kind
).toBe('typedef');

const namespace = inferKind(
177 changes: 98 additions & 79 deletions __tests__/lib/infer/membership.js

Large diffs are not rendered by default.

52 changes: 27 additions & 25 deletions __tests__/lib/infer/name.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const parse = require('../../../src/parsers/javascript');
const inferName = require('../../../src/infer/name');
import parse from '../../../src/parsers/javascript.js';
import inferName from '../../../src/infer/name.js';

function toComment(fn, file) {
return parse(
@@ -15,9 +15,9 @@ function evaluate(fn, file) {
return inferName(toComment(fn, file));
}

test('inferName', function() {
test('inferName', function () {
expect(
evaluate(function() {
evaluate(function () {
// ExpressionStatement (comment attached here)
// AssignmentExpression
// MemberExpression
@@ -28,18 +28,18 @@ test('inferName', function() {
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
// ExpressionStatement
// AssignmentExpression
// MemberExpression (comment attached here)
// FunctionExpression
/** Test */
exports.name = function() {};
exports.name = function () {};
}).name
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
exports = {
// Property (comment attached here)
// Identifier
@@ -51,7 +51,7 @@ test('inferName', function() {
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
exports = {
// Property
// Identifier (comment attached here)
@@ -63,7 +63,7 @@ test('inferName', function() {
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
exports = {
// Property
// Identifier (comment attached here)
@@ -75,98 +75,98 @@ test('inferName', function() {
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
/** Test */
function name() {}
}).name
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
/** Test */
const name = function() {};
const name = function () {};
}).name
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
/** Test */
const name = function name2() {};
}).name
).toBe('name');

expect(
evaluate(function() {
evaluate(function () {
/** @name explicitName */
function implicitName() {}
}).name
).toBe('explicitName');

expect(
evaluate(function() {
evaluate(function () {
/** @alias explicitAlias */
function implicitName() {}
}).name
).toBe('explicitAlias');

expect(
evaluate(function() {
evaluate(function () {
/** @class ExplicitClass */
function ImplicitClass() {}
}).name
).toBe('ExplicitClass');

expect(
evaluate(function() {
evaluate(function () {
/** @class */
function ImplicitClass() {}
}).name
).toBe('ImplicitClass');

expect(
evaluate(function() {
evaluate(function () {
/** @event explicitEvent */
function implicitName() {}
}).name
).toBe('explicitEvent');

expect(
evaluate(function() {
evaluate(function () {
/** @typedef {Object} ExplicitTypedef */
function implicitName() {}
}).name
).toBe('ExplicitTypedef');

expect(
evaluate(function() {
evaluate(function () {
/** @callback explicitCallback */
function implicitName() {}
}).name
).toBe('explicitCallback');

expect(
evaluate(function() {
evaluate(function () {
/** @module explicitModule */
function implicitName() {}
}).name
).toBe('explicitModule');

expect(
evaluate(function() {
evaluate(function () {
/** @module {Function} explicitModule */
function implicitName() {}
}).name
).toBe('explicitModule');

expect(
evaluate(function() {
evaluate(function () {
/** @module */
function implicitName() {}
}, '/path/inferred-from-file.js').name
).toBe('inferred-from-file');

expect(
evaluate(function() {
evaluate(function () {
/** @module */
}, '/path/inferred-from-file.js').name
).toBe('inferred-from-file');
@@ -194,7 +194,9 @@ test('inferName', function() {
expect(evaluate('/** Test */ export class Wizard {}').name).toBe('Wizard');

expect(evaluate('/** Test */ interface Wizard {}').name).toBe('Wizard');
expect(evaluate('/** Test */ interface Wizard {}', 'test.ts').name).toBe('Wizard');
expect(evaluate('/** Test */ interface Wizard {}', 'test.ts').name).toBe(
'Wizard'
);

expect(evaluate('/** Test */ enum Wizard {}', 'test.ts').name).toBe('Wizard');
expect(evaluate('enum Wizard { /** Test */ A }', 'test.ts').name).toBe('A');
47 changes: 26 additions & 21 deletions __tests__/lib/infer/params.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const parse = require('../../../src/parsers/javascript');
const inferParams = require('../../../src/infer/params');
import parse from '../../../src/parsers/javascript';
import inferParams, { mergeTrees } from '../../../src/infer/params';

function toComment(fn, file) {
return parse(
@@ -15,9 +15,9 @@ function evaluate(fn, file) {
return inferParams(toComment(fn, file));
}

test('mergeTrees', function() {
test('mergeTrees', function () {
expect(
inferParams.mergeTrees(
mergeTrees(
[],
[
{
@@ -34,7 +34,7 @@ test('mergeTrees', function() {
).toMatchSnapshot();

expect(
inferParams.mergeTrees(
mergeTrees(
[
{
title: 'param',
@@ -74,18 +74,18 @@ test('mergeTrees', function() {
).toMatchSnapshot();
});

test('inferParams', function() {
test('inferParams', function () {
expect(
evaluate(function() {
evaluate(function () {
/** Test */
function f(x) {}
}).params
).toEqual([{ lineNumber: 3, name: 'x', title: 'param' }]);

expect(
evaluate(function() {
evaluate(function () {
/** Test */
const f = function(x) {};
const f = function (x) {};
}).params
).toEqual([{ lineNumber: 3, name: 'x', title: 'param' }]);

@@ -114,13 +114,13 @@ test('inferParams', function() {
]);

expect(
evaluate(function() {
evaluate(function () {
const x = 1;
const g = function(y) {};
const g = function (y) {};
/** Test */
const f = function(x) {};
const f = function (x) {};
}).params
).toEqual([{ lineNumber: 8, name: 'x', title: 'param' }]);
).toEqual([{ lineNumber: 5, name: 'x', title: 'param' }]);

expect(
evaluate(
@@ -169,7 +169,7 @@ test('inferParams', function() {
).toEqual([{ lineNumber: 1, name: 'x', title: 'param' }]);

expect(
evaluate(function() {
evaluate(function () {
/**
* @class
* @hideconstructor
@@ -216,7 +216,7 @@ test('inferParams', function() {
).toMatchSnapshot();
});

test('inferParams (typescript)', function() {
test('inferParams (typescript)', function () {
expect(
evaluate(`/** Test */function f(a: string) {};`, 'test.ts').params
).toMatchSnapshot();
@@ -232,16 +232,18 @@ test('inferParams (typescript)', function() {
* @param x
*/
function f(x: number = 4) {}
`
, 'test.ts').params
`,
'test.ts'
).params
).toMatchSnapshot();

expect(
evaluate(
`
/** Test */
function f(opts: { x: string }) {}
` , 'test.ts'
`,
'test.ts'
).params
).toMatchSnapshot();

@@ -250,7 +252,8 @@ test('inferParams (typescript)', function() {
`
/** Test */
function f(opts: { [foo]: string }) {}
` , 'test.ts'
`,
'test.ts'
).params
).toMatchSnapshot();

@@ -271,7 +274,8 @@ test('inferParams (typescript)', function() {
).toMatchSnapshot();

expect(
evaluate(`abstract class Foo { /** */ abstract f(a?: string); }`, 'test.ts').params
evaluate(`abstract class Foo { /** */ abstract f(a?: string); }`, 'test.ts')
.params
).toMatchSnapshot();

expect(
@@ -283,6 +287,7 @@ test('inferParams (typescript)', function() {
).toMatchSnapshot();

expect(
evaluate(`interface Foo { /** b */ b(...v: string): void; }`, 'test.ts').params
evaluate(`interface Foo { /** b */ b(...v: string): void; }`, 'test.ts')
.params
).toMatchSnapshot();
});
15 changes: 9 additions & 6 deletions __tests__/lib/infer/properties.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-disable no-unused-vars*/
const inferProperties = require('../../../src/infer/properties');
const parse = require('../../../src/parsers/javascript');
import inferProperties from '../../../src/infer/properties';
import parse from '../../../src/parsers/javascript';

function toComment(fn, filename) {
return parse(
@@ -16,7 +16,7 @@ function evaluate(code, filename) {
return inferProperties(toComment(code, filename));
}

test('inferProperties (flow)', function() {
test('inferProperties (flow)', function () {
expect(evaluate('/** */type a = { b: 1 };').properties).toEqual([
{
lineNumber: 1,
@@ -65,7 +65,7 @@ test('inferProperties (flow)', function() {
]);
});

test('inferProperties (typescript)', function() {
test('inferProperties (typescript)', function () {
expect(evaluate('/** */type a = { b: 1 };', 'test.ts').properties).toEqual([
{
lineNumber: 1,
@@ -79,7 +79,8 @@ test('inferProperties (typescript)', function() {
]);

expect(
evaluate('/** @property {number} b */ type a = { b: 1 };', 'test.ts').properties
evaluate('/** @property {number} b */ type a = { b: 1 };', 'test.ts')
.properties
).toEqual([
{
lineNumber: 0,
@@ -92,7 +93,9 @@ test('inferProperties (typescript)', function() {
}
]);

expect(evaluate('/** */type a = { b: { c: 2 } };', 'test.ts').properties).toEqual([
expect(
evaluate('/** */type a = { b: { c: 2 } };', 'test.ts').properties
).toEqual([
{
lineNumber: 1,
name: 'b',
23 changes: 15 additions & 8 deletions __tests__/lib/infer/return.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-disable no-unused-vars*/
const inferReturn = require('../../../src/infer/return');
const parse = require('../../../src/parsers/javascript');
import inferReturn from '../../../src/infer/return';
import parse from '../../../src/parsers/javascript';

function toComment(fn, filename) {
return parse(
@@ -16,7 +16,7 @@ function evaluate(code, filename) {
return inferReturn(toComment(code, filename));
}

test('inferReturn (flow)', function() {
test('inferReturn (flow)', function () {
expect(evaluate('/** */function a(): number {}').returns).toEqual([
{
title: 'returns',
@@ -79,7 +79,7 @@ test('inferReturn (flow)', function() {
});
});

test('inferReturn (typescript)', function() {
test('inferReturn (typescript)', function () {
expect(evaluate('/** */function a(): number {}', 'test.ts').returns).toEqual([
{
title: 'returns',
@@ -89,7 +89,9 @@ test('inferReturn (typescript)', function() {
}
}
]);
expect(evaluate('/** */var a = function(): number {}', 'test.ts').returns).toEqual([
expect(
evaluate('/** */var a = function(): number {}', 'test.ts').returns
).toEqual([
{
title: 'returns',
type: {
@@ -99,7 +101,8 @@ test('inferReturn (typescript)', function() {
}
]);
expect(
evaluate('/** @returns {string} */function a(): number {}', 'test.ts').returns[0].type
evaluate('/** @returns {string} */function a(): number {}', 'test.ts')
.returns[0].type
).toEqual({
name: 'string',
type: 'NameExpression'
@@ -137,7 +140,10 @@ test('inferReturn (typescript)', function() {
}
]);

expect(evaluate('abstract class Test { /** */abstract a(): number; }', 'test.ts').returns).toEqual([
expect(
evaluate('abstract class Test { /** */abstract a(): number; }', 'test.ts')
.returns
).toEqual([
{
title: 'returns',
type: {
@@ -148,7 +154,8 @@ test('inferReturn (typescript)', function() {
]);

expect(
evaluate('interface Foo { /** */ bar(): string; }', 'test.ts').returns[0].type
evaluate('interface Foo { /** */ bar(): string; }', 'test.ts').returns[0]
.type
).toEqual({
name: 'string',
type: 'NameExpression'
10 changes: 5 additions & 5 deletions __tests__/lib/infer/type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const parse = require('../../../src/parsers/javascript');
const inferKind = require('../../../src/infer/kind');
const inferType = require('../../../src/infer/type');
import parse from '../../../src/parsers/javascript';
import inferKind from '../../../src/infer/kind';
import inferType from '../../../src/infer/type';

function toComment(fn, filename) {
return parse(
@@ -16,7 +16,7 @@ function evaluate(code, filename) {
return inferType(inferKind(toComment(code, filename)));
}

test('inferType (flow)', function() {
test('inferType (flow)', function () {
expect(evaluate('/** @typedef {T} V */').type).toEqual({
name: 'T',
type: 'NameExpression'
@@ -116,7 +116,7 @@ test('inferType (flow)', function() {
});
});

test('inferType (typescript)', function() {
test('inferType (typescript)', function () {
expect(evaluate('/** @typedef {T} V */', 'test.ts').type).toEqual({
name: 'T',
type: 'NameExpression'
14 changes: 7 additions & 7 deletions __tests__/lib/input/dependency.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const os = require('os');
const path = require('path');
const fs = require('fs');
const dependency = require('../../../src/input/dependency');
import os from 'os';
import path from 'path';
import fs from 'fs';
import dependency from '../../../src/input/dependency.js';

function inputs(contents) {
const dirEntry = os.tmpdir();
@@ -15,21 +15,21 @@ function inputs(contents) {
};
}

test('dependency', async function() {
test('dependency', async function () {
const { paths, cleanup } = inputs({
'index.js': 'module.exports = 1;',
'requires.js': "module.exports = require('./foo');",
'foo.js': 'module.exports = 2;'
});
{
const dependencies = await dependency([paths['index.js']], {
parseExtension: ['js']
parseExtension: ['.js']
});
expect(dependencies.length).toEqual(1);
}
{
const dependencies = await dependency([paths['requires.js']], {
parseExtension: ['js']
parseExtension: ['.js']
});
expect(dependencies.length).toEqual(2);
}
22 changes: 10 additions & 12 deletions __tests__/lib/input/shallow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const path = require('path');
const shallow = require('../../../src/input/shallow');
import path from 'path';
import shallow from '../../../src/input/shallow.js';
import { fileURLToPath } from 'url';

test('shallow deps', async function() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

test('shallow deps', async function () {
const deps = await shallow(
[path.resolve(path.join(__dirname, '../../fixture/es6.input.js'))],
{}
@@ -10,7 +14,7 @@ test('shallow deps', async function() {
expect(deps[0]).toBeTruthy();
});

test('shallow deps multi', async function() {
test('shallow deps multi', async function () {
const deps = await shallow(
[
path.resolve(path.join(__dirname, '../../fixture/es6.input.js')),
@@ -22,7 +26,7 @@ test('shallow deps multi', async function() {
expect(deps[0]).toBeTruthy();
});

test('shallow deps directory', async function() {
test('shallow deps directory', async function () {
const deps = await shallow(
[path.resolve(path.join(__dirname, '../../fixture/html'))],
{}
@@ -31,13 +35,7 @@ test('shallow deps directory', async function() {
expect(deps[0].file.match(/input.js/)).toBeTruthy();
});

test('throws on non-string or object input', function() {
return shallow([true], {}).catch(err => {
expect(err.message).toBe('Indexes should be either strings or objects');
});
});

test('shallow deps literal', async function() {
test('shallow deps literal', async function () {
const obj = {
file: 'foo.js',
source: '//bar'
19 changes: 9 additions & 10 deletions __tests__/lib/lint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const parse = require('../../src/parsers/javascript');
const lintComments = require('../../src/lint').lintComments;
const formatLint = require('../../src/lint').formatLint;
import parse from '../../src/parsers/javascript.js';
import { lintComments, formatLint } from '../../src/lint.js';

function toComment(fn, filename) {
return parse(
@@ -16,9 +15,9 @@ function evaluate(fn) {
return lintComments(toComment(fn, 'input.js'));
}

test('lintComments', function() {
test('lintComments', function () {
expect(
evaluate(function() {
evaluate(function () {
/**
* @param {foo
*/
@@ -29,15 +28,15 @@ test('lintComments', function() {
]);

expect(
evaluate(function() {
evaluate(function () {
/**
* @param {Object} foo.bar
*/
}).errors
).toEqual([{ commentLineNumber: 1, message: 'Parent of foo.bar not found' }]);

expect(
evaluate(function() {
evaluate(function () {
/**
* @param {String} foo
* @param {array} bar
@@ -52,16 +51,16 @@ test('lintComments', function() {
]);

expect(
evaluate(function() {
evaluate(function () {
/**
* @param {string} foo
*/
}).errors
).toEqual([]);
});

test('formatLint', function() {
const comment = evaluate(function() {
test('formatLint', function () {
const comment = evaluate(function () {
// 2
// 3
/** 4
187 changes: 98 additions & 89 deletions __tests__/lib/merge_config.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,112 @@
const path = require('path');
const _ = require('lodash');
const mergeConfig = require('../../src/merge_config');
import path from 'path';
import config from '../../src/config.js';
import mergeConfig from '../../src/merge_config.js';
import { fileURLToPath } from 'url';

test('bad config', async function() {
try {
await mergeConfig({ config: 'DOES-NOT-EXIST' });
} catch (err) {
expect(err).toBeTruthy();
}
});
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

test('right merging package configuration', async function() {
// Omit configuration from output, for simplicity
const nc = _.curryRight(_.omit, 2)([
'config',
'no-package',
'parseExtension',
'project-homepage',
'project-version',
'project-description'
]);
return mergeConfig({
config: path.join(__dirname, '../config_fixture/config.json'),
'no-package': true,
'project-name': 'cool Documentation'
})
.then(nc)
.then(res => {
expect(res).toEqual({
'project-name': 'cool Documentation',
foo: 'bar'
});
describe('single config tests', function () {
beforeEach(function () {
config.reset();
});

test('Should be failed on bad config', async function () {
try {
await mergeConfig({ config: 'DOES-NOT-EXIST' });
} catch (err) {
expect(err).toBeTruthy();
return;
}
return Promise.reject(new Error('should be failed on bad config'));
});

test('right merging package configuration', async function () {
const list = [
'config',
'no-package',
'parseExtension',
'project-homepage',
'project-version',
'project-description'
];
await mergeConfig({
config: path.join(__dirname, '../config_fixture/config.json'),
'no-package': true,
'project-name': 'cool Documentation'
});
});

test('nc(mergeConfig)', async function() {
// Omit configuration from output, for simplicity
const nc = _.curryRight(_.omit, 2)([
const res = config.globalConfig;
list.forEach(key => delete res[key]);
expect(res).toEqual({
'project-name': 'cool Documentation',
foo: 'bar'
});
});

const list = [
'config',
'no-package',
'parseExtension',
'project-homepage',
'project-name',
'project-version',
'project-description'
]);
];

return Promise.all(
[
[
{ config: path.join(__dirname, '../config_fixture/config.json') },
{ foo: 'bar' }
],
[
{
passThrough: true,
config: path.join(__dirname, '../config_fixture/config.json')
},
{ foo: 'bar', passThrough: true }
],
[
{
config: path.join(__dirname, '../config_fixture/config_comments.json')
},
{ foo: 'bar' }
],
[
[
{ config: path.join(__dirname, '../config_fixture/config.json') },
{ foo: 'bar' }
],
[
{
passThrough: true,
config: path.join(__dirname, '../config_fixture/config.json')
},
{ foo: 'bar', passThrough: true }
],
[
{
config: path.join(__dirname, '../config_fixture/config_comments.json')
},
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config.yaml') },
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config.yml') },
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config') },
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config_links.yml') },
{ foo: 'hello [link](https://github.com/my/link) world' }
],
[
{ config: path.join(__dirname, '../config_fixture/config_file.yml') },
{
toc: [
{
name: 'snowflake',
file: path.join(__dirname, '../fixture/snowflake.md')
}
]
}
]
].map(pair =>
mergeConfig(Object.assign(pair[0], { 'no-package': true }))
.then(nc)
.then(res => {
expect(res).toEqual(pair[1]);
})
)
);
{ config: path.join(__dirname, '../config_fixture/config.yaml') },
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config.yml') },
{ foo: 'bar' }
],
[
{ config: path.join(__dirname, '../config_fixture/config') },
{ foo: 'bar' }
],
[
{
config: path.join(__dirname, '../config_fixture/config_links.yml')
},
{ foo: 'hello [link](https://github.com/my/link) world' }
],
[
{ config: path.join(__dirname, '../config_fixture/config_file.yml') },
{
toc: [
{
name: 'snowflake',
file: path.join(__dirname, '../fixture/snowflake.md')
}
]
}
]
].forEach((pair, index) => {
test(`nc(mergeConfig) ${index}`, async function () {
await mergeConfig(Object.assign(pair[0], { 'no-package': true }));
const res = config.globalConfig;
list.forEach(key => delete res[key]);
expect(res).toEqual(pair[1]);
});
});
});
15 changes: 4 additions & 11 deletions __tests__/lib/module_filters.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
const moduleFilters = require('../../src/module_filters');
import internalOnly from '../../src/module_filters.js';

test('moduleFilters.internalOnly', function() {
expect(moduleFilters.internalOnly('./foo')).toEqual(true);
expect(moduleFilters.internalOnly('foo')).toEqual(false);
});

test('moduleFilters.externals', function() {
expect(moduleFilters.externals([], {})('./foo')).toEqual(true);
expect(
moduleFilters.externals([], { external: 'node_modules' })('./foo')
).toEqual(true);
test('moduleFilters.internalOnly', function () {
expect(internalOnly('./foo')).toEqual(true);
expect(internalOnly('foo')).toEqual(false);
});
12 changes: 6 additions & 6 deletions __tests__/lib/nest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const nestTag = require('../../src/nest').nestTag;
import { nestTag } from '../../src/nest.js';

// Print a tree of tags in a way that's easy to test.
const printTree = indent => node =>
@@ -9,7 +9,7 @@ const printTree = indent => node =>
const printNesting = params =>
printTree(0)({ properties: nestTag(params), name: 'root' });

test('nest params - basic', function() {
test('nest params - basic', function () {
const params = [
'foo',
'foo.bar',
@@ -27,7 +27,7 @@ test('nest params - basic', function() {
);
});

test('nest params - multiple roots', function() {
test('nest params - multiple roots', function () {
const params = ['a', 'b', 'c'].map(name => ({ name }));
expect(printNesting(params)).toBe(
`- root
@@ -37,14 +37,14 @@ test('nest params - multiple roots', function() {
);
});

test('nest params - missing parent', function() {
test('nest params - missing parent', function () {
const params = ['foo', 'foo.bar.third'].map(name => ({ name }));
expect(() => {
nestTag(params);
}).toThrow();
});

test('nest params - #658', function() {
test('nest params - #658', function () {
const params = [
'state',
'payload',
@@ -68,7 +68,7 @@ test('nest params - #658', function() {
);
});

test('nest params - #554', function() {
test('nest params - #554', function () {
const params = [
'x',
'yIn',
7 changes: 4 additions & 3 deletions __tests__/lib/output/util/formatters.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const formatters = require('../../../../src/output/util/formatters')(getHref);
import fromat from '../../../../src/output/util/formatters.js';
const formatters = fromat(getHref);

test('formatters.parameters -- long form', function() {
test('formatters.parameters -- long form', function () {
expect(formatters.parameters({})).toEqual('()');
expect(formatters.parameters({ params: [] })).toEqual('()');
expect(formatters.parameters({ params: [{ name: 'foo' }] })).toEqual(
@@ -13,7 +14,7 @@ test('formatters.parameters -- long form', function() {
).toEqual('(foo: any?)');
});

test('formatters.parameters -- short form', function() {
test('formatters.parameters -- short form', function () {
expect(formatters.parameters({}, true)).toEqual('()');
expect(formatters.parameters({ params: [] }, true)).toEqual('()');
expect(formatters.parameters({ params: [{ name: 'foo' }] }, true)).toEqual(
9 changes: 5 additions & 4 deletions __tests__/lib/parse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const parse = require('../../src/parsers/javascript');
const removePosition = require('../../src/remark-remove-position');
const remarkParse = require('remark')().use(removePosition).parse;
const visit = require('unist-util-visit');
import parse from '../../src/parsers/javascript.js';
import removePosition from '../../src/remark-remove-position.js';
import { remark } from 'remark';
const remarkParse = remark().use(removePosition).parse;
import { visit } from 'unist-util-visit';

function pick(obj, props) {
if (Array.isArray(props)) {
7 changes: 4 additions & 3 deletions __tests__/lib/parsers/javascript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const removePosition = require('../../../src/remark-remove-position');
const remarkParse = require('remark')().use(removePosition).parse;
const parse = require('../../../src/parsers/javascript');
import removePosition from '../../../src/remark-remove-position.js';
import { remark } from 'remark';
const remarkParse = remark().use(removePosition).parse;
import parse from '../../../src/parsers/javascript';

function toComments(source, filename, opts) {
source = typeof source === 'string' ? source : '(' + source.toString() + ')';
10 changes: 5 additions & 5 deletions __tests__/lib/parsers/parse_to_ast.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs');
const {
commentToFlow,
parseToAst
} = require('../../../src/parsers/parse_to_ast');
import fs from 'fs';
import { createRequire } from 'module';
import { commentToFlow, parseToAst } from '../../../src/parsers/parse_to_ast';

const require = createRequire(import.meta.url);

describe('flow comments', () => {
const f = require.resolve('../../fixture/flow/comment-types');
59 changes: 0 additions & 59 deletions __tests__/lib/server.js

This file was deleted.

49 changes: 20 additions & 29 deletions __tests__/lib/sort.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
const sort = require('../../src/sort');
const path = require('path');
import sort from '../../src/sort.js';
import path from 'path';
import { fileURLToPath } from 'url';

test('sort stream alphanumeric', function () {
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const banana = { context: { sortKey: 'c' }, name: 'bananas' };
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

expect(sort([apples, carrot, banana])).toEqual([apples, carrot, banana]);
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

expect(sort([carrot, apples, banana])).toEqual([apples, carrot, banana]);
test('sort stream alphanumeric', function () {
expect(sort([apples, carrot, bananas])).toEqual([apples, carrot, bananas]);
expect(sort([carrot, apples, bananas])).toEqual([apples, carrot, bananas]);
});

test('sort stream with configuration', function () {
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

expect(
sort([apples, carrot, bananas], {
toc: ['carrot', 'bananas']
@@ -24,10 +23,6 @@ test('sort stream with configuration', function () {
});

test('sort stream with configuration and a section', function () {
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

const section = {
name: 'This is the banana type',
description: 'here lies bananas'
@@ -67,10 +62,6 @@ test('sort stream with configuration and a section', function () {

test('sort an already-sorted stream containing a section/description', function () {
// this happens in the 'serve' task
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

const section = {
name: 'This is the banana type',
description: 'here lies bananas'
@@ -110,10 +101,6 @@ test('sort an already-sorted stream containing a section/description', function
});

test('sort toc with files', function () {
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

const snowflake = {
name: 'snowflake',
file: path.join(__dirname, '../fixture/snowflake.md')
@@ -127,10 +114,6 @@ test('sort toc with files', function () {
});

test('sort toc with files absolute path', function () {
const apples = { context: { sortKey: 'a' }, name: 'apples' };
const carrot = { context: { sortKey: 'b' }, name: 'carrot' };
const bananas = { context: { sortKey: 'c' }, name: 'bananas' };

const snowflake = {
name: 'snowflake',
file: path.join(__dirname, '../fixture/snowflake.md')
@@ -146,6 +129,7 @@ test('sort toc with files absolute path', function () {
const apples = {
context: { sortKey: 'a' },
name: 'apples',
kind: 'function',
memberof: 'classB'
};
const carrot = {
@@ -156,6 +140,7 @@ test('sort toc with files absolute path', function () {
const bananas = {
context: { sortKey: 'c' },
name: 'bananas',
kind: 'function',
memberof: 'classB'
};

@@ -165,7 +150,13 @@ test('sort toc with files absolute path', function () {
};
expect(
sort([carrot, apples, bananas], {
sortOrder: 'alpha'
sortOrder: ['alpha']
})
).toMatchSnapshot();

expect(
sort([carrot, apples, bananas], {
sortOrder: ['kind', 'alpha']
})
).toMatchSnapshot();
});
7 changes: 4 additions & 3 deletions __tests__/lib/ts_doctrine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const tsDoctrine = require('../../src/ts_doctrine.js');
const parse = require('../../src/parsers/javascript');
const TSTYPE_TYPES = require('@babel/types').TSTYPE_TYPES;
import tsDoctrine from '../../src/ts_doctrine.js';
import parse from '../../src/parsers/javascript';
import babelTypes from '@babel/types';
const TSTYPE_TYPES = babelTypes.TSTYPE_TYPES;

function toComment(fn, filename) {
return parse(
8 changes: 4 additions & 4 deletions __tests__/lib/walk.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const walk = require('../../src/walk').walk;
import walk from '../../src/walk.js';

describe('walk', function() {
test('flat comments', function() {
describe('walk', function () {
test('flat comments', function () {
const comments = [{ name: 'Tom' }];

function renamer(comment, options) {
@@ -19,7 +19,7 @@ describe('walk', function() {
]);
});

test('nested comments', function() {
test('nested comments', function () {
const comments = [
{
name: 'Tom',
2 changes: 1 addition & 1 deletion __tests__/linker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const LinkerStack = require('../src/output/util/linker_stack');
import LinkerStack from '../src/output/util/linker_stack.js';

test('linkerStack', function () {
const linkerStack = new LinkerStack({});
73 changes: 34 additions & 39 deletions __tests__/test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
const documentationSchema = require('documentation-schema');
const validate = require('json-schema');
const documentation = require('../');
const outputMarkdown = require('../src/output/markdown.js');
const outputMarkdownAST = require('../src/output/markdown_ast.js');
const outputHtml = require('../src/output/html.js');
const normalize = require('./utils').normalize;
const glob = require('glob');
const pify = require('pify');
const path = require('path');
const fs = require('fs');
const _ = require('lodash');
const chdir = require('chdir');
import documentationSchema from 'documentation-schema';
import validate from 'json-schema';
import * as documentation from '../src/index';
import outputMarkdown from '../src/output/markdown.js';
import outputMarkdownAST from '../src/output/markdown_ast.js';
import outputHtml from '../src/output/html.js';
import { normalize } from './utils';
import glob from 'glob';
import pify from 'pify';
import path from 'path';
import fs from 'fs';
import _ from 'lodash';
import chdir from 'chdir';
import config from '../src/config';
import { fileURLToPath } from 'url';

const UPDATE = !!process.env.UPDATE;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function makePOJO(ast) {
return JSON.parse(JSON.stringify(ast));
@@ -30,9 +34,12 @@ function readOptionsFromFile(file) {
return {};
}

beforeEach(function () {
config.reset();
});

if (fs.existsSync(path.join(__dirname, '../.git'))) {
test('git option', async function () {
jest.setTimeout(10000); // 10 second timeout. After update flow.js on 0.56 version the test is executed more time.
const file = path.join(__dirname, './fixture/simple.input.js');
const result = await documentation.build([file], { github: true });
normalize(result);
@@ -52,19 +59,15 @@ test('document-exported error', async function () {
}
});

test('external modules option', async function () {
const result = await documentation.build(
[path.join(__dirname, 'fixture', 'external.input.js')],
{
external: '(external|external/node_modules/*)'
}
);
test('Check that external modules could parse as input', async function () {
const dir = path.join(__dirname, 'fixture');
const result = await documentation.build([
path.join(dir, 'node_modules', 'external', 'lib', 'main.js'),
path.join(dir, 'node_modules', 'external2', 'index.js'),
path.join(dir, 'external.input.js')
]);
normalize(result);
const outputfile = path.join(
__dirname,
'fixture',
'_external-deps-included.json'
);
const outputfile = path.join(dir, '_external-deps-included.json');
expect(result).toMatchSnapshot();
});

@@ -95,21 +98,13 @@ describe('html', function () {
.sync(path.join(__dirname, 'fixture/html', '*.input.js'))
.forEach(function (file) {
test(path.basename(file), async function () {
const result = await documentation.build(
[file],
readOptionsFromFile(file)
);
const options = readOptionsFromFile(file);
const result = await documentation.build([file], options);
const html = await outputHtml(result, {});
const clean = html
.sort((a, b) => a.path > b.path)
.filter(r => r.path.match(/(html)$/))
.map(r =>
r.contents
.toString()
.replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '')
.replace(/<code>\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, '')
)
.join('\n');
.replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '')
.replace(/<code>\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, '');

expect(clean).toMatchSnapshot();
});
});
27 changes: 4 additions & 23 deletions __tests__/utils.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
const http = require('http');
const { walk } = require('../src/walk');
const concat = require('concat-stream');
import walk from '../src/walk.js';
import http from 'http';

function get(url, callback) {
return new Promise((resolve, reject) => {
http.get(url, function (res) {
res.pipe(
concat(function (text) {
if (res.statusCode >= 400) {
return reject(res.statusCode);
}
resolve(text.toString());
})
);
});
});
}

function normalize(comments) {
export function normalize(comments) {
return walk(comments, function (comment) {
const hasGithub = !!comment.context.github;
const path = comment.context.path;
@@ -36,7 +20,7 @@ function normalize(comments) {
});
}

module.exports.mockRepo = {
export const mockRepo = {
master: {
'/my': {
repository: {
@@ -132,6 +116,3 @@ module.exports.mockRepo = {
}
}
};

module.exports.get = get;
module.exports.normalize = normalize;
29 changes: 4 additions & 25 deletions bin/documentation.js
Original file line number Diff line number Diff line change
@@ -2,24 +2,15 @@

/* eslint no-console: 0 */

const yargs = require('yargs');
const commands = require('../src/commands');
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import commands from '../src/commands/index.js';

const argv = yargs
yargs(hideBin(process.argv))
.strict()
.command(commands.serve)
.command(commands.build)
.command(commands.lint)
.command(commands.readme)
.fail(function(msg, error) {
if (error) {
throw error;
} else {
yargs.showHelp('error');
console.error(msg);
return yargs.exit(1);
}
})
.example('documentation build foo.js -f md > API.md')
.example('documentation readme index.js -s "API Docs" --github')
.version()
@@ -50,15 +41,3 @@ const argv = yargs
)
.recommendCommands()
.help().argv;

if (argv.private) {
console.error(
'--private is deprecated, please use the --access (or -a) option instead'
);
console.error('for example: -a public -a private -a protected -a undefined');
}

if (!argv._handled) {
yargs.showHelp('error');
process.exit(1);
}
7 changes: 1 addition & 6 deletions docs/NODE_API.md
Original file line number Diff line number Diff line change
@@ -126,14 +126,9 @@ Formats documentation as HTML.

```javascript
var documentation = require('documentation');
var streamArray = require('stream-array');
var vfs = require('vinyl-fs');

documentation.build(['index.js'])
.then(documentation.formats.html)
.then(output => {
streamArray(output).pipe(vfs.dest('./output-directory'));
});
.then(documentation.formats.html);
```

Returns **[Promise][21]<[Array][17]<[Object][19]>>** Promise with results
11 changes: 4 additions & 7 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
@@ -40,15 +40,10 @@ Options:
--no-package, --np dont find and use package.json for project-
configuration option defaults
[boolean] [default: false]
--external a string / glob match pattern that defines which
external modules will be whitelisted and included
in the generated documentation. [default: null]
--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.
--private, -p generate documentation tagged as private
[boolean] [default: false]
--access, -a Include only comments with a given access level,
out of private, protected, public, undefined. By
default, public, protected, and undefined access
@@ -61,8 +56,10 @@ Options:
--document-exported Generate documentation for all exported bindings
and members even if there is no JSDoc for them
[boolean] [default: false]
--sort-order The order to sort the documentation
[choices: "source", "alpha"] [default: "source"]
--sort-order The order to sort the documentation, may be
specified multiple times
[choices: "source", "alpha", "kind"]
[default: "source"]
--output, -o output location. omit for stdout, otherwise is a
filename for single-file outputs and a directory
name for multi-file outputs like html
Loading