@alloy-js/markdown 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +7 -0
  2. package/api-extractor.json +4 -0
  3. package/dist/src/components/Heading.d.ts +9 -0
  4. package/dist/src/components/Heading.d.ts.map +1 -0
  5. package/dist/src/components/Heading.js +6 -0
  6. package/dist/src/components/Link.d.ts +11 -0
  7. package/dist/src/components/Link.d.ts.map +1 -0
  8. package/dist/src/components/Link.js +7 -0
  9. package/dist/src/components/List.d.ts +16 -0
  10. package/dist/src/components/List.d.ts.map +1 -0
  11. package/dist/src/components/List.js +26 -0
  12. package/dist/src/components/Section.d.ts +7 -0
  13. package/dist/src/components/Section.d.ts.map +1 -0
  14. package/dist/src/components/Section.js +32 -0
  15. package/dist/src/components/SourceFile.d.ts +7 -0
  16. package/dist/src/components/SourceFile.d.ts.map +1 -0
  17. package/dist/src/components/SourceFile.js +20 -0
  18. package/dist/src/components/index.d.ts +2 -0
  19. package/dist/src/components/index.d.ts.map +1 -0
  20. package/dist/src/components/index.js +0 -0
  21. package/dist/src/context/section.d.ts +7 -0
  22. package/dist/src/context/section.d.ts.map +1 -0
  23. package/dist/src/context/section.js +11 -0
  24. package/dist/src/index.d.ts +2 -0
  25. package/dist/src/index.d.ts.map +1 -0
  26. package/dist/src/index.js +1 -0
  27. package/dist/test/list.test.d.ts +2 -0
  28. package/dist/test/list.test.d.ts.map +1 -0
  29. package/dist/test/list.test.js +49 -0
  30. package/dist/test/paragraph.test.d.ts +2 -0
  31. package/dist/test/paragraph.test.d.ts.map +1 -0
  32. package/dist/test/paragraph.test.js +36 -0
  33. package/dist/test/section.test.d.ts +2 -0
  34. package/dist/test/section.test.d.ts.map +1 -0
  35. package/dist/test/section.test.js +61 -0
  36. package/dist/test/utils.d.ts +3 -0
  37. package/dist/test/utils.d.ts.map +1 -0
  38. package/dist/test/utils.js +13 -0
  39. package/dist/test/vitest.d.js +1 -0
  40. package/dist/tsconfig.tsbuildinfo +1 -0
  41. package/package.json +34 -0
  42. package/src/components/Heading.tsx +19 -0
  43. package/src/components/Link.tsx +24 -0
  44. package/src/components/List.tsx +50 -0
  45. package/src/components/Section.tsx +24 -0
  46. package/src/components/SourceFile.tsx +14 -0
  47. package/src/components/index.ts +0 -0
  48. package/src/context/section.ts +17 -0
  49. package/src/index.ts +1 -0
  50. package/temp/api.json +177 -0
  51. package/test/list.test.tsx +53 -0
  52. package/test/paragraph.test.tsx +42 -0
  53. package/test/section.test.tsx +55 -0
  54. package/test/utils.tsx +10 -0
  55. package/test/vitest.d.ts +16 -0
  56. package/tsconfig.json +11 -0
  57. package/tsdoc-metadata.json +11 -0
  58. package/vitest.config.ts +10 -0
@@ -0,0 +1,42 @@
1
+ import { Prose } from "@alloy-js/core";
2
+ import "@alloy-js/core/testing";
3
+ import { expect, it } from "vitest";
4
+ import { Section } from "../src/components/Section.jsx";
5
+ import { mdTest } from "./utils.jsx";
6
+
7
+ it("renders a section", () => {
8
+ const template = mdTest(
9
+ <Section heading="hello">
10
+ <Prose>
11
+ This is some text content that should be wrapped and such. We can put
12
+ *italic* and **bold** text here, and it should be rendered correctly. We
13
+ can also put in some code: `const x = 1;` and it should be rendered
14
+ correctly. We can also put in some links:
15
+ [Alloy](https://alloy-framework.github.io/alloy). It's pretty nice.
16
+ </Prose>
17
+ <Prose>
18
+ Subsequent paragraphs should have a blank line between them.
19
+ </Prose>
20
+ </Section>,
21
+ );
22
+
23
+ expect(template).toRenderTo(
24
+ `
25
+ # hello
26
+
27
+ This is some text content that should be
28
+ wrapped and such. We can put *italic*
29
+ and **bold** text here, and it should be
30
+ rendered correctly. We can also put in
31
+ some code: \`const x = 1;\` and it should
32
+ be rendered correctly. We can also put
33
+ in some links:
34
+ [Alloy](https://alloy-framework.github.io/alloy).
35
+ It's pretty nice.
36
+
37
+ Subsequent paragraphs should have a
38
+ blank line between them.
39
+ `,
40
+ { printWidth: 40 },
41
+ );
42
+ });
@@ -0,0 +1,55 @@
1
+ import "@alloy-js/core/testing";
2
+ import { expect, it } from "vitest";
3
+ import { Section } from "../src/components/Section.jsx";
4
+ import { mdTest } from "./utils.jsx";
5
+
6
+ it("renders a section", () => {
7
+ const template = mdTest([<Section heading="hello">world</Section>]);
8
+
9
+ expect(template).toRenderTo(`
10
+ # hello
11
+
12
+ world
13
+ `);
14
+ });
15
+
16
+ it("renders multiple sections", () => {
17
+ const template = mdTest([
18
+ <Section heading="hello">world</Section>,
19
+ <Section heading="hello">world</Section>,
20
+ ]);
21
+
22
+ expect(template).toRenderTo(`
23
+ # hello
24
+
25
+ world
26
+
27
+ # hello
28
+
29
+ world
30
+ `);
31
+ });
32
+
33
+ it("renders nested sections", () => {
34
+ const template = mdTest([
35
+ <Section heading="hello">
36
+ world
37
+ <Section heading="subhello">subworld</Section>
38
+ </Section>,
39
+ <Section heading="hello">world</Section>,
40
+ ]);
41
+
42
+ expect(template).toRenderTo(`
43
+ # hello
44
+
45
+ world
46
+
47
+ ## subhello
48
+
49
+ subworld
50
+
51
+ # hello
52
+
53
+ world
54
+ `);
55
+ });
package/test/utils.tsx ADDED
@@ -0,0 +1,10 @@
1
+ import { Children, Output } from "@alloy-js/core";
2
+ import { SourceFile } from "../src/components/SourceFile.jsx";
3
+
4
+ export function mdTest(children: Children) {
5
+ return (
6
+ <Output>
7
+ <SourceFile path="test.md">{children}</SourceFile>
8
+ </Output>
9
+ );
10
+ }
@@ -0,0 +1,16 @@
1
+ import "vitest";
2
+
3
+ interface ToRenderToRenderOptions {
4
+ printWidth?: number;
5
+ tabWidth?: number;
6
+ useTabs?: boolean;
7
+ }
8
+
9
+ interface CustomMatchers<R = unknown> {
10
+ toRenderTo: (str: string, options?: ToRenderToRenderOptions) => R;
11
+ }
12
+
13
+ declare module "vitest" {
14
+ interface Assertion<T = any> extends CustomMatchers<T> {}
15
+ interface AsymmetricMatchersContaining extends CustomMatchers {}
16
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "emitDeclarationOnly": true,
5
+ "declaration": true,
6
+ "outDir": "dist"
7
+ },
8
+ "references": [{ "path": "../core" }],
9
+ "include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],
10
+ "exclude": ["node_modules", "dist"]
11
+ }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.47.12"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,10 @@
1
+ import alloyPlugin from "@alloy-js/rollup-plugin";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ esbuild: {
6
+ jsx: "preserve",
7
+ sourcemap: "both",
8
+ },
9
+ plugins: [alloyPlugin()],
10
+ });