diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index c2ffa2b..0000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -coverage/ -_site/ -dist/ diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 4d387a6..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: ['@advanced-rest-client/eslint-config'].map(require.resolve), -}; diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..a73904c --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,101 @@ +name: Tests and publishing +env: + FORCE_COLOR: 1 +on: + push: + branches: + - master + - main + - develop + pull_request: + branches: + - master + - main +jobs: + test_linux: + name: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + # os: [ubuntu-18.04, ubuntu-20.04] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14 + - uses: microsoft/playwright-github-action@v1 + - uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm test + test_win: + name: "Windows" + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14 + - uses: microsoft/playwright-github-action@v1 + - uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm test + tag: + name: "Publishing release" + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + needs: + - test_linux + - test_win + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '14.x' + registry-url: 'https://registry.npmjs.org' + - uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm install + - name: Read version from package.json + uses: culshaw/read-package-node-version-actions@v1 + id: package-node-version + - name: Changelog + uses: scottbrenner/generate-changelog-action@master + id: Changelog + - name: Github Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.package-node-version.outputs.version }} + release_name: v${{ steps.package-node-version.outputs.version }} + body: | + ${{ steps.Changelog.outputs.changelog }} + draft: false + prerelease: false + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index c6695bd..4d27f0f 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,7 @@ $RECYCLE.BIN/ node_modules coverage + +# AMF models +/demo/*.json +!demo/apis.json diff --git a/.npmignore b/.npmignore index a128a97..d3c386a 100644 --- a/.npmignore +++ b/.npmignore @@ -1,14 +1,8 @@ coverage/ test/ demo/ -gen-tsd.json -CONTRIBUTING.md -.travis.yml -index.html -polymer.json -karma.* -husky.* -commitlint.* +tsconfig.json +web-test-runner.config.mjs .* *.config.* -prettier.config.js +karma.conf.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a88ac11..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: node_js -node_js: stable -sudo: required -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable -script: - - npm test - - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:sl; fi -env: - global: - - secure: >- - ZtCawohQaFmJXh+wAeHUSOFRcKjbnzPQLIITBubITgzdUzkmuSuj4bHYHwEI6xVlwHh0J9vJhrJIaLA8ZAT7MlchGXLa+2ASg1KomAoaa4xjA0B8HvYFBLBZ+4tkVx4q7WPE3/5Iw0EAX4YTSkJk8cXF48KXtlMMaS7o2PL0Zr/unQ9TeDU9Lpo+2JMVkDKnEyk8mnSv0OkRfVcutYVo0tp4kNuBEIfNKSm7hj8NUtAPzF98nU0Iz7HektAHNUtAaFDJD3RaeYzUOnB7F99MvT8kpLIwtjldRI6QnROanrRc5r9RW0k6Nq7r6g8RoIfUoigzUUp/AmhFY/1R/fQHPmJomWSy01WPAr3q2rXOM0rQoZMJgO1hZYpiD3seenqEq2rtYtMTLva0OY/ItmqGE0KsPjM/857w4G7L8rqY1mxwyyDTU92KiGRx173ilrRZZkmpiaw5C+zhIWZDAGs+ORQGY6FbmRTG5j8KgiZDLYm0MkkYaM7rF0FqItHE7tQp6KJjixGtGsuNGYy56gSwgTJO8dnehr+MqNYJUY4JYm0Gty39v8SFnRItcvGewzqRDvdktmbiMK7lFMjxw4Cmfwt+ltkXfXRI7D/0Kll9aQyqJ48FEkFCASgpcMXPto99y/8ffm3WfSRmFiy9B/o2N9Y8f9pC4Wj2WbXiBKUkc3w= - - secure: >- - kY5NsOfX2CQDDsL/yzLuFaH3JQe+yEzv9Kj5Nj2BqQLdKt3M/iSaE7faF8FGl6ATBEIp46/4gga/zY2/nikvnexkvleV9lwj7zaPhZEyQBcAiVmENrmaps0lgP4xHbQu+6lqzX93XmkjsMqe0y3Nlm+zrvjgeHeg1iFI9/cwAhDmGpcSPVYf64jF5fDPqEgCnEF3ZADlW8CLUgo2aupyfY/boBZFW7j0/ATnz7pQ2Y4Mi/rUNsE9BPUW3bRtU9+yip+OoOHo3htmpMX46Z0RFfD3Y8j8zcVD0hHcAZkjPi0ksveqJmR2bR9Xoghdm8xTlJBrzeoc5IYMeBNEzxbisV7GICL8exUyltgUxlkSg23mfM2ATUwXfqRKdC+8RIsaJo+MD548J3VNp20X6efNLGGdnIuQ7fxziRs5qy+qlux8DKqZEmNfFvafuNvdDr40Ku0A1zwfwN6hY/kWMkLBb0cIuLe4gBbSzosGI5QC0wHShYluArFqlPfmtr4uDb/FLnB+fHfXmPzo+O8v6t2JhYBgH1QulULHpO+lkkYcvTmYB7l1VFpCVPF7FS51zLU4JM+l0O6fFjPrrsYyvLdlt4iTHJA29RTj2Z6NIlmLDUfI2Pu5g1ZKS9v/eaJv6KLR0N4Ug9buXCyDP7i3NuCjXbxY+aSllArbxc3MzJ4x2PE= diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index ad26d2e..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,150 +0,0 @@ - -## 2.0.1 (2019-01-20) - - -### Docs - -* Updating docs ([98d1ca067a3f80a9597ed8804a9965c863d78ea3](https://github.com/advanced-rest-client/api-documentation-document/commit/98d1ca067a3f80a9597ed8804a9965c863d78ea3)) -* Updating documentation. ([304f850d2b56cee6f092af05bd6dcfd0c1d6061c](https://github.com/advanced-rest-client/api-documentation-document/commit/304f850d2b56cee6f092af05bd6dcfd0c1d6061c)) -* Updating readme page ([c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3](https://github.com/advanced-rest-client/api-documentation-document/commit/c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3)) - -### New - -* Adding support for compact model ([ee475301fd914231fd46044b49f152711a632922](https://github.com/advanced-rest-client/api-documentation-document/commit/ee475301fd914231fd46044b49f152711a632922)) - -### Update - -* Updated Travis configuration to connect to Sauce Labs. ([1456c55b56dc8e5a1a7fab7a48cd431264f85213](https://github.com/advanced-rest-client/api-documentation-document/commit/1456c55b56dc8e5a1a7fab7a48cd431264f85213)) - - - - -## 2.0.1 (2018-08-29) - - -### Docs - -* Updating docs ([98d1ca067a3f80a9597ed8804a9965c863d78ea3](https://github.com/advanced-rest-client/api-documentation-document/commit/98d1ca067a3f80a9597ed8804a9965c863d78ea3)) -* Updating documentation. ([304f850d2b56cee6f092af05bd6dcfd0c1d6061c](https://github.com/advanced-rest-client/api-documentation-document/commit/304f850d2b56cee6f092af05bd6dcfd0c1d6061c)) -* Updating readme page ([c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3](https://github.com/advanced-rest-client/api-documentation-document/commit/c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3)) - -### New - -* Adding support for compact model ([ee475301fd914231fd46044b49f152711a632922](https://github.com/advanced-rest-client/api-documentation-document/commit/ee475301fd914231fd46044b49f152711a632922)) - -### Update - -* Updated Travis configuration to connect to Sauce Labs. ([1456c55b56dc8e5a1a7fab7a48cd431264f85213](https://github.com/advanced-rest-client/api-documentation-document/commit/1456c55b56dc8e5a1a7fab7a48cd431264f85213)) - - - - -# 2.0.0 (2018-05-21) - - -### Docs - -* Updating documentation. ([304f850d2b56cee6f092af05bd6dcfd0c1d6061c](https://github.com/advanced-rest-client/api-documentation-document/commit/304f850d2b56cee6f092af05bd6dcfd0c1d6061c)) - -### Update - -* Updated Travis configuration to connect to Sauce Labs. ([1456c55b56dc8e5a1a7fab7a48cd431264f85213](https://github.com/advanced-rest-client/api-documentation-document/commit/1456c55b56dc8e5a1a7fab7a48cd431264f85213)) - - - -# 3.0.0 (2019-06-19) - - -### Docs - -* Updating docs ([98d1ca067a3f80a9597ed8804a9965c863d78ea3](https://github.com/advanced-rest-client/api-documentation-document/commit/98d1ca067a3f80a9597ed8804a9965c863d78ea3)) -* Updating documentation. ([304f850d2b56cee6f092af05bd6dcfd0c1d6061c](https://github.com/advanced-rest-client/api-documentation-document/commit/304f850d2b56cee6f092af05bd6dcfd0c1d6061c)) -* Updating readme page ([c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3](https://github.com/advanced-rest-client/api-documentation-document/commit/c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3)) - -### New - -* Adding support for compact model ([ee475301fd914231fd46044b49f152711a632922](https://github.com/advanced-rest-client/api-documentation-document/commit/ee475301fd914231fd46044b49f152711a632922)) - -### Update - -* Updated Travis configuration to connect to Sauce Labs. ([1456c55b56dc8e5a1a7fab7a48cd431264f85213](https://github.com/advanced-rest-client/api-documentation-document/commit/1456c55b56dc8e5a1a7fab7a48cd431264f85213)) - - - -## 3.0.1 (2019-08-25) - - - -## 3.0.2 (2019-09-30) - - - -## 3.0.3 (2019-10-05) - - -### Bug Fixes - -* fixes APIC-268 - clicking on relative links ([004d506](https://github.com/advanced-rest-client/api-documentation-document/commit/004d506)) - - - -# 4.0.0 (2019-10-13) - - -### Bug Fixes - -* fixes APIC-268 - clicking on relative links ([004d506](https://github.com/advanced-rest-client/api-documentation-document/commit/004d506)) - - - -## 4.0.1 (2019-11-08) - - -### Bug Fixes - -* fixes APIC-268 - clicking on relative links ([004d506](https://github.com/advanced-rest-client/api-documentation-document/commit/004d506fe881c56c041734d61102385e311ad7fb)) - - - - -## [4.0.2](https://github.com/advanced-rest-client/api-documentation-document/compare/4.0.0...4.0.2) (2019-11-14) - -### Build - -* bumping version [2206c92](https://github.com/advanced-rest-client/api-documentation-document/commit/2206c92eb7d44ba1c84596f4238545609caba62e) by Pawel -* bumping version [099f75d](https://github.com/advanced-rest-client/api-documentation-document/commit/099f75d83a04cccfa41954828437a3b7ca163355) by Pawel - - -### Update - -* embed css styles in render method [bump-version] [788cb97](https://github.com/advanced-rest-client/api-documentation-document/commit/788cb97f7976a9a89df71d2aef1118d98cdeb774) by Francisco Di Giandomenico -* embed css styles in render method (#2) [bump-version] [254871e](https://github.com/advanced-rest-client/api-documentation-document/commit/254871e5dc0c4b45276a32e2eb2199bb224b53f3) by Francisco Di Giandomenico -* adding sanitize option to the MD reader [09ae963](https://github.com/advanced-rest-client/api-documentation-document/commit/09ae963b8795b1518d5ceb6aa195b7393d3a177b) by Pawel Psztyc -* replacing `amf` setter with the function call [af11aca](https://github.com/advanced-rest-client/api-documentation-document/commit/af11aca2c317c8182f618bf48f2033fa6c7922d3) by Pawel -* upgrading project to latest ARC standard [359f3c9](https://github.com/advanced-rest-client/api-documentation-document/commit/359f3c931412ab0b294e261ed1f297edd43f64ba) by Pawel - - -### Bug Fixes - -* fixes APIC-268 - clicking on relative links [004d506](https://github.com/advanced-rest-client/api-documentation-document/commit/004d506fe881c56c041734d61102385e311ad7fb) by Pawel - - -### Refactor - -* upgrading to AMF version 4 [6d770ae](https://github.com/advanced-rest-client/api-documentation-document/commit/6d770ae478cee660203c7f3da62d7a05657a9f19) by Pawel - - -### Other - -* Docs: Updating docs - [98d1ca0](https://github.com/advanced-rest-client/api-documentation-document/commit/98d1ca067a3f80a9597ed8804a9965c863d78ea3) by Pawel Psztyc -* Docs: Updating readme page - [c720e2a](https://github.com/advanced-rest-client/api-documentation-document/commit/c720e2a7935c1bfa975f7f80f3a00cc9ba8d03c3) by Pawel Psztyc -* New: Adding support for compact model - [ee47530](https://github.com/advanced-rest-client/api-documentation-document/commit/ee475301fd914231fd46044b49f152711a632922) by Pawel Psztyc -* Docs: Updating documentation. - [304f850](https://github.com/advanced-rest-client/api-documentation-document/commit/304f850d2b56cee6f092af05bd6dcfd0c1d6061c) by Pawel Psztyc -* Update: Updated Travis configuration to connect to Sauce Labs. - [1456c55](https://github.com/advanced-rest-client/api-documentation-document/commit/1456c55b56dc8e5a1a7fab7a48cd431264f85213) by Pawel Psztyc - - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 6c7da44..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,74 +0,0 @@ -# Guide for Contributors - -The Advanced REST client is open and we encourage the community to contribute in the project. However, it is very important to follow couple of simple rules when you create an issue report or send a pull request. - -## Issue reporting -**If this is feature request**, please provide a clear description of the feature. I've created a [document][87714bdc] that may help you fill up a feature request. But basically you should answer this questions: - -- Who will benefit from this feature? _("Someone who is trying to...")_ -- What's the use cases (when the feature will be used)? _("When the HTTP response is...")_ -- What the user gain by having this feature? _("I should be able to see...")_ - -An overview of the feature would be nice as well. - -**When you're filling a bug report**, please be as much specific as you can and: - -- A clear description of the bug, logs if available and your expectations. You're welcome to use following template: -```markdown -The send button causes the app to close itself. - -## Expected outcome -The app is not closing itself when I try to send a request. - -## Actual outcome -After click it is working for couple of second and the it closes itself. - -# Versions -App: 1.2.3 (check it in app's about page) -Chrome: Stable (or) 47.0.111.111 (check it in Chrome's about page) - -# Steps to reproduce -1. Turn off CodeMirror -2. Set method to "PUT" -3. Use "raw" tab for both payload and headers -4. Paste following data into the headers field: ... -5. Paste following data into the payload field: ... -6. Run the request. -``` - -## Submitting Pull Requests -**While developing**, be sure that you follow the [design guidelines] for ARC. - -**Before creating a pull request**, fill up `changelog.md` file inside the elements folder. It is the best way of keeping track of change reasons. Try be very specific and put there only essential information about the changes. - -Then a good idea is to test your code. See testing paragraph in the dev-start file. It will save all of us a lot of trouble. - -Please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with ARC authors and community before diving into a pull request. - -When submitting pull requests, please provide: -1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues using the following syntax: - - ```markdown - (For a single issue) - Fixes #20 - - (For multiple issues) - Fixes #32, #40 - ``` - Github automatically close the issues after merging it to the master. So please, keep the format. - - 2. **A succinct description of the design** used to fix any related issues. For example: - - ```markdown - This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked. - ``` - - 3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered. - -If a proposed change contains multiple commits, please [squash commits](http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. - -_Part of this document has been copied from Polymer repository. Thanks guys!_ - - - [87714bdc]: https://docs.google.com/document/d/10OPWl9Hagk6Oz--VUztQBTOpm3QP2Vv__PrH3zZ7wFQ/edit?usp=sharing "Feature request file" - [Design guidelines]: diff --git a/api-documentation-document.d.ts b/api-documentation-document.d.ts index 6fa5aaa..466fa11 100644 --- a/api-documentation-document.d.ts +++ b/api-documentation-document.d.ts @@ -1,70 +1,7 @@ -/** - * DO NOT EDIT - * - * This file was automatically generated by - * https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations - * - * To modify these typings, edit the source file(s): - * api-documentation-document.js - */ - - -// tslint:disable:variable-name Describing an API that's defined elsewhere. -// tslint:disable:no-any describes the API as best we are able today - -import {LitElement, html, css} from 'lit-element'; - -import {AmfHelperMixin} from '@api-components/amf-helper-mixin/amf-helper-mixin.js'; - -declare namespace ApiElements { - - /** - * `api-documentation-document` - * - * A component to render documentation node of the AMF model - * - * Markdown styles are defined in `advanced-rest-client/markdown-styles`. - */ - class ApiDocumentationDocument extends - AmfHelperMixin( - Object) { - - /** - * A Document to render. - * Represents AMF's shape for document. - */ - shape: object|null|undefined; - - /** - * Computed value of the title of the documentation. - * Might be undefined. - */ - _title: string|null|undefined; - - /** - * Computed value of content of documentation. - */ - _content: string|null|undefined; - render(): any; - - /** - * Computes `title` and `content` properties when `shape` changes. - * - * @param shape Value of the `shape` attrribute - */ - _shapeChanged(shape: object|null): void; - - /** - * At current state there's no way to tell where to navigate when relative - * link is clicked. To prevent 404 anchores this prevents any relative link click. - */ - _clickHandler(e: Event|null): void; - } -} +import { ApiDocumentationDocumentElement } from './src/ApiDocumentationDocumentElement'; declare global { - interface HTMLElementTagNameMap { - "api-documentation-document": ApiElements.ApiDocumentationDocument; + "api-documentation-document": ApiDocumentationDocumentElement; } } diff --git a/api-documentation-document.js b/api-documentation-document.js index 55a803d..4bfb68d 100644 --- a/api-documentation-document.js +++ b/api-documentation-document.js @@ -1,115 +1,3 @@ -import { LitElement, html, css } from 'lit-element'; -import { AmfHelperMixin } from '@api-components/amf-helper-mixin/amf-helper-mixin.js'; -import markdownStyles from '@advanced-rest-client/markdown-styles/markdown-styles.js'; -import '@advanced-rest-client/arc-marked/arc-marked.js'; -/** - * `api-documentation-document` - * - * A component to render documentation node of the AMF model - * - * Markdown styles are defined in `advanced-rest-client/markdown-styles`. - * - * @customElement - * @demo demo/index.html - * @memberof ApiElements - * @appliesMixin AmfHelperMixin - */ -class ApiDocumentationDocument extends AmfHelperMixin(LitElement) { - get styles() { - return [ - markdownStyles, - css`:host { - display: block; - } +import { ApiDocumentationDocumentElement } from './src/ApiDocumentationDocumentElement.js'; - h1 { - font-size: var(--arc-font-headline-font-size); - font-weight: var(--arc-font-headline-font-weight); - letter-spacing: var(--arc-font-headline-letter-spacing); - line-height: var(--arc-font-headline-line-height); - } - - arc-marked { - background-color: transparent; - padding: 0; - }` - ]; - } - - render() { - const { _title: title, _content: content } = this; - const hasTitle = !!title; - return html` -
- ${hasTitle ? html`

${title}

` : undefined} - -
-
-
`; - } - - static get properties() { - return { - /** - * A Document to render. - * Represents AMF's shape for document. - */ - shape: { type: Object }, - /** - * Computed value of the title of the documentation. - * Might be undefined. - */ - _title: { type: String }, - /** - * Computed value of content of documentation. - */ - _content: { type: String } - }; - } - - get shape() { - return this._shape; - } - - set shape(value) { - const old = this._shape; - if (old === value) { - return; - } - this._shape = value; - this.requestUpdate('shape', old); - this._shapeChanged(value); - } - - __amfChanged() { - this._shapeChanged(this.shape); - } - /** - * Computes `title` and `content` properties when `shape` changes. - * @param {Object} shape Value of the `shape` attrribute - */ - _shapeChanged(shape) { - this._title = this._getValue(shape, this.ns.aml.vocabularies.core.title); - this._content = this._getValue(shape, this.ns.aml.vocabularies.core.description); - } - /** - * At current state there's no way to tell where to navigate when relative - * link is clicked. To prevent 404 anchores this prevents any relative link click. - * @param {Event} e - */ - _clickHandler(e) { - const { target } = e; - if (target.localName !== 'a') { - return; - } - // target.href is always absolute, need attribute value to test for - // relative links. - const href = target.getAttribute('href'); - const ch0 = href[0]; - if (['.', '/'].indexOf(ch0) !== -1) { - e.preventDefault(); - e.stopPropagation(); - } - } -} -window.customElements.define('api-documentation-document', ApiDocumentationDocument); +window.customElements.define('api-documentation-document', ApiDocumentationDocumentElement); diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index c34aa79..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: ['@commitlint/config-conventional'] -}; diff --git a/custom-elements.json b/custom-elements.json new file mode 100644 index 0000000..2337ce1 --- /dev/null +++ b/custom-elements.json @@ -0,0 +1,30 @@ +{ + "version": "experimental", + "tags": [ + { + "name": "api-documentation-document", + "path": "./api-documentation-document.js", + "description": "`api-documentation-document`\n\nA component to render documentation node of the AMF model\n\nMarkdown styles are defined in `advanced-rest-client/markdown-styles`.", + "properties": [ + { + "name": "styles", + "type": "CSSResult[]" + }, + { + "name": "shape", + "description": "A Document to render.\nRepresents AMF's shape for document." + }, + { + "name": "ns", + "description": "A namespace for AMF model.", + "type": "Namespace" + }, + { + "name": "amf", + "description": "Generated AMF json/ld model form the API spec.\nThe element assumes the object of the first array item to be a\ntype of `\"http://raml.org/vocabularies/document#Document`\non AMF vocabulary.\n\nIt is only useful for the element to resolve references.", + "type": "object | object[] | undefined" + } + ] + } + ] +} \ No newline at end of file diff --git a/demo/demo-api-compact.json b/demo/demo-api-compact.json deleted file mode 100644 index cca4581..0000000 --- a/demo/demo-api-compact.json +++ /dev/null @@ -1,498 +0,0 @@ -[ -{ -"@id": "", -"@type": [ -"doc:Document", -"doc:Fragment", -"doc:Module", -"doc:Unit" -], -"doc:encodes": [ -{ -"@id": "#3", -"@type": [ -"apiContract:WebAPI", -"doc:RootDomainElement", -"doc:DomainElement" -], -"core:name": [ -{ -"@value": "My super cool, example API" -} -], -"apiContract:server": [ -{ -"@id": "#4", -"@type": [ -"apiContract:Server", -"doc:DomainElement" -], -"core:urlTemplate": [ -{ -"@value": "http://api.domain.com/" -} -], -"sourcemaps:sources": [ -{ -"@id": "#4/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:urlTemplate" -} -], -"sourcemaps:value": [ -{ -"@value": "[(4,0)-(6,0)]" -} -] -} -], -"sourcemaps:synthesized-field": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#4" -} -], -"sourcemaps:value": [ -{ -"@value": "true" -} -] -} -] -} -] -} -], -"core:version": [ -{ -"@value": "v1" -} -], -"core:documentation": [ -{ -"@id": "#5", -"@type": [ -"core:CreativeWork", -"doc:DomainElement" -], -"core:title": [ -{ -"@value": "Read this!" -} -], -"core:description": [ -{ -"@value": "# This is an example API spec\nThe API doesn't exists in the real world therefore calls made to any endpoint will always fail.\nIf you'd like to perform actual request and see the response try GitHub API (which doesn't require user authentication in some endpoints) or other APIs.\nNote that you may need a Client ID or valid authorization token to perform a call to some APIs that are secured by the OAuth 2 protocol.\n\nTest of links:\n- [relative link](../demo-document/demo-document.raml)\n- [absolute link](https://mulesoft.com)\n\nThank you for testing the API console. Your feedback is welcome. Email us: arc@mulesoft.com\n" -} -], -"sourcemaps:sources": [ -{ -"@id": "#5/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:description" -} -], -"sourcemaps:value": [ -{ -"@value": "[(8,4)-(19,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#5" -} -], -"sourcemaps:value": [ -{ -"@value": "[(7,4)-(19,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:title" -} -], -"sourcemaps:value": [ -{ -"@value": "[(7,4)-(8,0)]" -} -] -} -] -} -] -}, -{ -"@id": "#2", -"@type": [ -"core:CreativeWork", -"doc:DomainElement" -], -"core:title": [ -{ -"@value": "About" -} -], -"core:description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"sourcemaps:sources": [ -{ -"@id": "#2/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:source-vendor": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#2" -} -], -"sourcemaps:value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:description" -} -], -"sourcemaps:value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#2" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:title" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -}, -{ -"@id": "#6", -"@type": [ -"core:CreativeWork", -"doc:DomainElement" -], -"core:title": [ -{ -"@value": "Test docs" -} -], -"core:description": [ -{ -"@value": "# A test documentation.\nThis text was created by ARC's RAML editor.\nYou probably see this because you are testing ARC's web components and this component\nis responsible for displaying a documentation from the RAML definition.\nPlay around with the element and use it in your project.\nPlease, note the licensing information available in every ARC component.\nIf you have any question email me: arc@mulesoft.com\nOr slack me (internally only): Pawel Psztyc (P3)\n" -} -], -"sourcemaps:sources": [ -{ -"@id": "#6/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:description" -} -], -"sourcemaps:value": [ -{ -"@value": "[(21,4)-(30,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#6" -} -], -"sourcemaps:value": [ -{ -"@value": "[(20,4)-(30,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:title" -} -], -"sourcemaps:value": [ -{ -"@value": "[(20,4)-(21,0)]" -} -] -} -] -} -] -} -], -"sourcemaps:sources": [ -{ -"@id": "#3/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:source-vendor": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#3" -} -], -"sourcemaps:value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:documentation" -} -], -"sourcemaps:value": [ -{ -"@value": "[(6,0)-(30,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "apiContract:server" -} -], -"sourcemaps:value": [ -{ -"@value": "[(4,0)-(6,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#3" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(30,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:name" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:version" -} -], -"sourcemaps:value": [ -{ -"@value": "[(3,0)-(4,0)]" -} -] -} -] -} -] -} -], -"doc:version": [ -{ -"@value": "2.0.0" -} -], -"doc:references": [ -{ -"@id": "#1", -"@type": [ -"apiContract:UserDocumentationFragment", -"doc:Fragment", -"doc:Unit" -], -"doc:encodes": [ -{ -"@id": "#2", -"@type": [ -"core:CreativeWork", -"doc:DomainElement" -], -"core:title": [ -{ -"@value": "About" -} -], -"core:description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"sourcemaps:sources": [ -{ -"@id": "#2/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:source-vendor": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#2" -} -], -"sourcemaps:value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:description" -} -], -"sourcemaps:value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#2" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:title" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -} -], -"doc:version": [ -{ -"@value": "2.0.0" -} -], -"sourcemaps:sources": [ -{ -"@id": "#1/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#1" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -} -] -} -] -} -], -"@context": { -"@base": "amf://id", -"doc": "http://a.ml/vocabularies/document#", -"apiContract": "http://a.ml/vocabularies/apiContract#", -"core": "http://a.ml/vocabularies/core#", -"sourcemaps": "http://a.ml/vocabularies/document-source-maps#" -} -} -] diff --git a/demo/demo-api.json b/demo/demo-api.json deleted file mode 100644 index 1a42e44..0000000 --- a/demo/demo-api.json +++ /dev/null @@ -1,491 +0,0 @@ -[ -{ -"@id": "amf://id", -"@type": [ -"http://a.ml/vocabularies/document#Document", -"http://a.ml/vocabularies/document#Fragment", -"http://a.ml/vocabularies/document#Module", -"http://a.ml/vocabularies/document#Unit" -], -"http://a.ml/vocabularies/document#encodes": [ -{ -"@id": "amf://id#3", -"@type": [ -"http://a.ml/vocabularies/apiContract#WebAPI", -"http://a.ml/vocabularies/document#RootDomainElement", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#name": [ -{ -"@value": "My super cool, example API" -} -], -"http://a.ml/vocabularies/apiContract#server": [ -{ -"@id": "amf://id#4", -"@type": [ -"http://a.ml/vocabularies/apiContract#Server", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#urlTemplate": [ -{ -"@value": "http://api.domain.com/" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#4/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#urlTemplate" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(4,0)-(6,0)]" -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#synthesized-field": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#4" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "true" -} -] -} -] -} -] -} -], -"http://a.ml/vocabularies/core#version": [ -{ -"@value": "v1" -} -], -"http://a.ml/vocabularies/core#documentation": [ -{ -"@id": "amf://id#5", -"@type": [ -"http://a.ml/vocabularies/core#CreativeWork", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#title": [ -{ -"@value": "Read this!" -} -], -"http://a.ml/vocabularies/core#description": [ -{ -"@value": "# This is an example API spec\nThe API doesn't exists in the real world therefore calls made to any endpoint will always fail.\nIf you'd like to perform actual request and see the response try GitHub API (which doesn't require user authentication in some endpoints) or other APIs.\nNote that you may need a Client ID or valid authorization token to perform a call to some APIs that are secured by the OAuth 2 protocol.\n\nTest of links:\n- [relative link](../demo-document/demo-document.raml)\n- [absolute link](https://mulesoft.com)\n\nThank you for testing the API console. Your feedback is welcome. Email us: arc@mulesoft.com\n" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#5/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#description" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(8,4)-(19,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#5" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(7,4)-(19,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#title" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(7,4)-(8,0)]" -} -] -} -] -} -] -}, -{ -"@id": "amf://id#2", -"@type": [ -"http://a.ml/vocabularies/core#CreativeWork", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#title": [ -{ -"@value": "About" -} -], -"http://a.ml/vocabularies/core#description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#2/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#source-vendor": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#2" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#description" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#2" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#title" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -}, -{ -"@id": "amf://id#6", -"@type": [ -"http://a.ml/vocabularies/core#CreativeWork", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#title": [ -{ -"@value": "Test docs" -} -], -"http://a.ml/vocabularies/core#description": [ -{ -"@value": "# A test documentation.\nThis text was created by ARC's RAML editor.\nYou probably see this because you are testing ARC's web components and this component\nis responsible for displaying a documentation from the RAML definition.\nPlay around with the element and use it in your project.\nPlease, note the licensing information available in every ARC component.\nIf you have any question email me: arc@mulesoft.com\nOr slack me (internally only): Pawel Psztyc (P3)\n" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#6/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#description" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(21,4)-(30,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#6" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(20,4)-(30,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#title" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(20,4)-(21,0)]" -} -] -} -] -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#3/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#source-vendor": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#3" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#documentation" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(6,0)-(30,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/apiContract#server" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(4,0)-(6,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#3" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(30,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#name" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#version" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(3,0)-(4,0)]" -} -] -} -] -} -] -} -], -"http://a.ml/vocabularies/document#version": [ -{ -"@value": "2.0.0" -} -], -"http://a.ml/vocabularies/document#references": [ -{ -"@id": "amf://id#1", -"@type": [ -"http://a.ml/vocabularies/apiContract#UserDocumentationFragment", -"http://a.ml/vocabularies/document#Fragment", -"http://a.ml/vocabularies/document#Unit" -], -"http://a.ml/vocabularies/document#encodes": [ -{ -"@id": "amf://id#2", -"@type": [ -"http://a.ml/vocabularies/core#CreativeWork", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#title": [ -{ -"@value": "About" -} -], -"http://a.ml/vocabularies/core#description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#2/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#source-vendor": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#2" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#description" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#2" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#title" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -} -], -"http://a.ml/vocabularies/document#version": [ -{ -"@value": "2.0.0" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#1/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#1" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -} -] -} -] -} -] -} -] diff --git a/demo/demo-document-compact.json b/demo/demo-document-compact.json deleted file mode 100644 index c35c0de..0000000 --- a/demo/demo-document-compact.json +++ /dev/null @@ -1,123 +0,0 @@ -[ -{ -"@id": "", -"@type": [ -"apiContract:UserDocumentationFragment", -"doc:Fragment", -"doc:Unit" -], -"doc:encodes": [ -{ -"@id": "#1", -"@type": [ -"core:CreativeWork", -"doc:DomainElement" -], -"core:title": [ -{ -"@value": "About" -} -], -"core:description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"sourcemaps:sources": [ -{ -"@id": "#1/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:source-vendor": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#1" -} -], -"sourcemaps:value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "core:description" -} -], -"sourcemaps:value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "amf://id#1" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"sourcemaps:element": [ -{ -"@value": "core:title" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -} -], -"doc:version": [ -{ -"@value": "2.0.0" -} -], -"sourcemaps:sources": [ -{ -"@id": "#/source-map", -"@type": [ -"sourcemaps:SourceMap" -], -"sourcemaps:lexical": [ -{ -"sourcemaps:element": [ -{ -"@value": "amf://id" -} -], -"sourcemaps:value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -} -] -} -], -"@context": { -"@base": "amf://id", -"doc": "http://a.ml/vocabularies/document#", -"apiContract": "http://a.ml/vocabularies/apiContract#", -"core": "http://a.ml/vocabularies/core#", -"sourcemaps": "http://a.ml/vocabularies/document-source-maps#" -} -} -] diff --git a/demo/demo-document.json b/demo/demo-document.json deleted file mode 100644 index 0ce5618..0000000 --- a/demo/demo-document.json +++ /dev/null @@ -1,116 +0,0 @@ -[ -{ -"@id": "amf://id", -"@type": [ -"http://a.ml/vocabularies/apiContract#UserDocumentationFragment", -"http://a.ml/vocabularies/document#Fragment", -"http://a.ml/vocabularies/document#Unit" -], -"http://a.ml/vocabularies/document#encodes": [ -{ -"@id": "amf://id#1", -"@type": [ -"http://a.ml/vocabularies/core#CreativeWork", -"http://a.ml/vocabularies/document#DomainElement" -], -"http://a.ml/vocabularies/core#title": [ -{ -"@value": "About" -} -], -"http://a.ml/vocabularies/core#description": [ -{ -"@value": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#1/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#source-vendor": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#1" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "RAML 1.0" -} -] -} -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#description" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(3,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id#1" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -}, -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "http://a.ml/vocabularies/core#title" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(3,0)]" -} -] -} -] -} -] -} -], -"http://a.ml/vocabularies/document#version": [ -{ -"@value": "2.0.0" -} -], -"http://a.ml/vocabularies/document-source-maps#sources": [ -{ -"@id": "amf://id#/source-map", -"@type": [ -"http://a.ml/vocabularies/document-source-maps#SourceMap" -], -"http://a.ml/vocabularies/document-source-maps#lexical": [ -{ -"http://a.ml/vocabularies/document-source-maps#element": [ -{ -"@value": "amf://id" -} -], -"http://a.ml/vocabularies/document-source-maps#value": [ -{ -"@value": "[(2,0)-(22,0)]" -} -] -} -] -} -] -} -] diff --git a/demo/index.html b/demo/index.html index 5938591..ca58b1f 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,10 +5,6 @@ api-documentation-document demo - - - - +
+ ${hasTitle ? html`

${title}

` : undefined} + +
+
+
`; + } + + static get properties() { + return { + /** + * A Document to render. + * Represents AMF's shape for document. + */ + shape: { type: Object }, + /** + * Computed value of the title of the documentation. + * Might be undefined. + */ + _title: { type: String }, + /** + * Computed value of content of documentation. + */ + _content: { type: String } + }; + } + + get shape() { + return this._shape; + } + + set shape(value) { + const old = this._shape; + if (old === value) { + return; + } + this._shape = value; + this.requestUpdate('shape', old); + this._shapeChanged(value); + } + + __amfChanged() { + this._shapeChanged(this.shape); + } + + /** + * Computes `title` and `content` properties when `shape` changes. + * @param {any} shape Value of the `shape` attribute + */ + _shapeChanged(shape) { + this._title = /** @type string */ (this._getValue(shape, this.ns.aml.vocabularies.core.title)); + this._content = /** @type string */ (this._getValue(shape, this.ns.aml.vocabularies.core.description)); + } + + /** + * At current state there's no way to tell where to navigate when relative + * link is clicked. To prevent 404 anchors this prevents any relative link click. + * @param {Event} e + */ + _clickHandler(e) { + const node = /** @type HTMLElement */ (e.target); + if (node.localName !== 'a') { + return; + } + // target.href is always absolute, need attribute value to test for + // relative links. + const href = node.getAttribute('href'); + const ch0 = href[0]; + if (['.', '/'].indexOf(ch0) !== -1) { + e.preventDefault(); + e.stopPropagation(); + } + } +} diff --git a/src/styles.js b/src/styles.js new file mode 100644 index 0000000..013d277 --- /dev/null +++ b/src/styles.js @@ -0,0 +1,19 @@ +import { css } from 'lit-element'; + +export default css` +:host { + display: block; +} + +h1 { + font-size: var(--arc-font-headline-font-size); + font-weight: var(--arc-font-headline-font-weight); + letter-spacing: var(--arc-font-headline-letter-spacing); + line-height: var(--arc-font-headline-line-height); +} + +arc-marked { + background-color: transparent; + padding: 0; +} +`; diff --git a/test/api-documentation-document.test.js b/test/api-documentation-document.test.js index 7fe9122..e5ca40b 100644 --- a/test/api-documentation-document.test.js +++ b/test/api-documentation-document.test.js @@ -1,23 +1,30 @@ import { fixture, assert, html } from '@open-wc/testing'; -import { AmfLoader } from './amf-loader.js'; -import * as sinon from 'sinon/pkg/sinon-esm.js'; +import sinon from 'sinon'; import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions.js'; +import { AmfLoader } from './amf-loader.js'; import '../api-documentation-document.js'; -describe('', function() { +/** @typedef {import('../').ApiDocumentationDocumentElement} ApiDocumentationDocumentElement */ + +describe('', () => { + /** + * @param {any} amf + * @param {any} shape + * @returns {Promise} + */ async function basicFixture(amf, shape) { - return (await fixture(html``)); + .shape="${shape}">`); } [ ['Full AMF model', false], ['Compact AMF model', true] ].forEach(([label, compact]) => { - describe(label, () => { + describe(String(label), () => { describe('Basics', () => { - let element; + let element = /** @type ApiDocumentationDocumentElement */ (null); let amf; let docs; @@ -54,7 +61,7 @@ describe('', function() { assert.isFalse(spy.called); }); - it('Does not call _shapeChanged() when setting the same sape value', () => { + it('Does not call _shapeChanged() when setting the same shape value', () => { const spy = sinon.spy(element, '_shapeChanged'); element.shape = docs; assert.isFalse(spy.called); @@ -62,7 +69,7 @@ describe('', function() { }); describe('Navigation', () => { - let element; + let element = /** @type ApiDocumentationDocumentElement */ (null); let amf; let docs; let anchors; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..85841f7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "lib": ["es2017", "dom"], + "allowJs": true, + "checkJs": true, + "noEmit": true, + "strict": false, + "noImplicitThis": true, + "alwaysStrict": true, + "esModuleInterop": true, + "plugins": [ + { + "name": "typescript-lit-html-plugin" + } + ] + }, + "include": [ + "**/*.js", + "node_modules/@open-wc/**/*.js" + ], + "exclude": [ + "node_modules/!(@open-wc)" + ] +} diff --git a/web-test-runner.config.mjs b/web-test-runner.config.mjs new file mode 100644 index 0000000..192f94d --- /dev/null +++ b/web-test-runner.config.mjs @@ -0,0 +1,12 @@ +export default { + files: 'test/**/*.test.js', + nodeResolve: true, + middleware: [ + function rewriteBase(context, next) { + if (context.url.indexOf('/base') === 0) { + context.url = context.url.replace('/base', '') + } + return next(); + } + ] +};