-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
markdown
and markdown/table
- Loading branch information
1 parent
c0f368b
commit 10b8d14
Showing
11 changed files
with
564 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Target Corporation. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
import { expect } from 'chai'; | ||
import StyleDictionary from 'style-dictionary'; | ||
import { fs } from 'style-dictionary/fs'; | ||
import { resolve } from '../lib/resolve.js'; | ||
import { buildPath } from './_constants.js'; | ||
import { clearOutput } from '../__tests__/__helpers.js'; | ||
|
||
describe('integration', async () => { | ||
before(async () => { | ||
const sd = new StyleDictionary({ | ||
source: [`__integration__/tokens/**/[!_]*.json?(c)`], | ||
platforms: { | ||
markdown: { | ||
transformGroup: `markdown`, | ||
buildPath, | ||
files: [ | ||
{ | ||
destination: 'StyleDictionary.md', | ||
format: 'markdown/table', | ||
}, | ||
{ | ||
destination: 'StyleDictionaryWithReferences.md', | ||
format: 'markdown/table', | ||
options: { | ||
outputReferences: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
await sd.buildAllPlatforms(); | ||
}); | ||
|
||
afterEach(() => { | ||
clearOutput(buildPath); | ||
}); | ||
|
||
describe('markdown', async () => { | ||
describe(`markdown/table`, async () => { | ||
it(`should match snapshot`, async () => { | ||
const output = fs.readFileSync(resolve(`${buildPath}StyleDictionary.md`), { | ||
encoding: `UTF-8`, | ||
}); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
|
||
describe(`with references`, async () => { | ||
it(`should match snapshot`, async () => { | ||
const output = fs.readFileSync(resolve(`${buildPath}StyleDictionaryWithReferences.md`), { | ||
encoding: `UTF-8`, | ||
}); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @typedef {import('../../../../types/DesignToken.ts').TransformedToken} TransformedToken | ||
* @typedef {import('../../../../types/Config.ts').Config} Config | ||
* @typedef {import('../../../../types/Config.ts').LocalOptions} LocalOptions | ||
*/ | ||
|
||
/** | ||
* @param {{ | ||
* allTokens: TransformedToken[] | ||
* formatProperty: (token: TransformedToken) => string | ||
* options: Config & LocalOptions | ||
* header: string | ||
* }} opts | ||
*/ | ||
export default ({ allTokens, formatProperty, options, header }) => ` | ||
${header} | ||
| Token | Description | Type | Value | | ||
| --- | --- | --- | --- | | ||
${allTokens | ||
.map( | ||
(token) => | ||
`| ${token.name} | ${token.$description ? token.$description : token.comment ?? ''} | ${token.original.type} | \u0060${options.usesDtcg ? JSON.stringify(token.original.$value) : token.original.value}\u0060 |`, | ||
) | ||
.join('\n')} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.