react-lib-tools 0.0.20 → 0.0.21

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.
@@ -11,6 +11,9 @@ import { MouseEvent as MouseEvent_2 } from 'react';
11
11
  import { PropsWithChildren } from 'react';
12
12
  import { ReactNode } from 'react';
13
13
 
14
+ /**
15
+ * Displays an application shell with desktop and mobile layouts.
16
+ */
14
17
  export declare function AppRoot({ navLinks, overview, packageDescription, packageName, routes, showOpenCollectLink, versions }: {
15
18
  navLinks: ReactNode;
16
19
  overview?: ReactNode | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-lib-tools",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
6
6
  "contributors": [
@@ -10,16 +10,35 @@ import {
10
10
  ScriptTarget
11
11
  } from "typescript";
12
12
 
13
+ /**
14
+ * Compile TSDoc comments into a formatted structure that can be rendered by the `ComponentProps` component.
15
+ */
13
16
  export async function compileDocs({
14
17
  analyserOptions: analyserOptionsParam,
15
18
  componentNames = [],
16
19
  imperativeHandleNames = [],
17
- outputDirName = "docs"
20
+ outputPath = ["public", "generated", "docs"]
18
21
  }: {
22
+ /**
23
+ * AST Parser config; see `@ts-ast-parser/core` documentation for more information.
24
+ */
19
25
  analyserOptions?: Partial<AnalyserOptions>;
26
+
27
+ /**
28
+ * Which components should be compiled?
29
+ */
20
30
  componentNames?: string[] | undefined;
31
+
32
+ /**
33
+ * Which imperative handles should be compiled?
34
+ */
21
35
  imperativeHandleNames?: string[] | undefined;
22
- outputDirName?: string | undefined;
36
+
37
+ /**
38
+ * Where should the output be stored?
39
+ * By default examples are stored within the `public/generated/docs` directory.
40
+ */
41
+ outputPath?: string[] | undefined;
23
42
  }) {
24
43
  const compilerOptions: Partial<CompilerOptions> = {
25
44
  ...defaultCompilerOptions,
@@ -35,13 +54,13 @@ export async function compileDocs({
35
54
  await compileComponents({
36
55
  compilerOptions,
37
56
  componentNames,
38
- outputDirName
57
+ outputPath
39
58
  });
40
59
 
41
60
  await compileImperativeHandles({
42
61
  analyserOptions,
43
62
  names: imperativeHandleNames,
44
- outputDirName
63
+ outputPath
45
64
  });
46
65
  }
47
66
 
@@ -1,22 +1,39 @@
1
1
  import { readFile, writeFile } from "node:fs/promises";
2
2
  import { basename, join } from "node:path";
3
+ import { trimExcludedText } from "./utils/examples/trimExcludedText.ts";
3
4
  import { initialize } from "./utils/initialize.ts";
4
5
  import { syntaxHighlight } from "./utils/syntax-highlight.ts";
5
- import { trimExcludedText } from "./utils/examples/trimExcludedText.ts";
6
6
 
7
+ /**
8
+ * Compile example snippets into syntax-highlighted HTML that can be rendered by the `Code` component.
9
+ */
7
10
  export async function compileExamples({
8
- fileExtensions = [".css", ".html", ".ts", ".tsx"],
11
+ fileExtensions = [".css", ".html", ".js", ".jsx", ".ts", ".tsx"],
9
12
  inputPath = ["src", "routes"],
10
- outputDirName = "examples"
13
+ outputPath = ["public", "generated", "examples"]
11
14
  }: {
15
+ /**
16
+ * Which file extension are supported?
17
+ * By default CSS, HTML, TS/TSX, and JS/JSX file extensions are supported.
18
+ */
12
19
  fileExtensions?: string[] | undefined;
20
+
21
+ /**
22
+ * Where are example files located?
23
+ * By default this script looks for examples within the `src/routes` root directory.
24
+ */
13
25
  inputPath?: string[] | undefined;
14
- outputDirName?: string | undefined;
26
+
27
+ /**
28
+ * Where should the output be stored?
29
+ * By default examples are stored within the `public/generated/examples` directory.
30
+ */
31
+ outputPath?: string[] | undefined;
15
32
  } = {}) {
16
33
  const { files, outputDir } = await initialize({
17
34
  fileExtensions,
18
35
  inputPath,
19
- outputDirName
36
+ outputPath
20
37
  });
21
38
 
22
39
  for (const file of files) {
@@ -10,11 +10,11 @@ import { insertPropsMarkdown } from "./insertPropsMarkdown.ts";
10
10
  export async function compileComponents({
11
11
  compilerOptions,
12
12
  componentNames,
13
- outputDirName
13
+ outputPath
14
14
  }: {
15
15
  compilerOptions: Partial<CompilerOptions>;
16
16
  componentNames: string[];
17
- outputDirName: string;
17
+ outputPath: string[];
18
18
  }) {
19
19
  const parser = withCompilerOptions(compilerOptions, {
20
20
  savePropValueAsString: true,
@@ -30,7 +30,7 @@ export async function compileComponents({
30
30
  file.includes(`${componentName}.ts`)
31
31
  ),
32
32
  inputPath: ["lib", "components"],
33
- outputDirName
33
+ outputPath
34
34
  });
35
35
 
36
36
  const markdownPath = join(cwd(), "README.md");
@@ -10,13 +10,13 @@ import { compileImperativeHandle } from "./compileImperativeHandle.ts";
10
10
  export async function compileImperativeHandles({
11
11
  analyserOptions,
12
12
  names,
13
- outputDirName
13
+ outputPath
14
14
  }: {
15
15
  analyserOptions: Partial<AnalyserOptions>;
16
16
  names: string[];
17
- outputDirName: string;
17
+ outputPath: string[];
18
18
  }) {
19
- const outputDir = join(cwd(), "public", "generated", outputDirName);
19
+ const outputDir = join(cwd(), ...outputPath);
20
20
 
21
21
  const result = await parseFromProject(analyserOptions);
22
22
  const reflectedModules = result.project?.getModules() ?? [];
@@ -8,15 +8,15 @@ export async function initialize({
8
8
  fileExtensions,
9
9
  fileFilter,
10
10
  inputPath,
11
- outputDirName
11
+ outputPath
12
12
  }: {
13
13
  fileExtensions: string[];
14
14
  fileFilter?: ((path: string) => boolean) | undefined;
15
15
  inputPath: string[];
16
- outputDirName: string;
16
+ outputPath: string[];
17
17
  }) {
18
18
  const inputDir = join(cwd(), ...inputPath);
19
- const outputDir = join(cwd(), "public", "generated", outputDirName);
19
+ const outputDir = join(cwd(), ...outputPath);
20
20
  await mkdir(outputDir, { recursive: true });
21
21
  await rmFilesWithExtensions(outputDir, [".json"]);
22
22