@shd101wyy/yo 0.1.12 → 0.1.13

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 (164) hide show
  1. package/README.md +10 -1
  2. package/out/cjs/index.cjs +578 -572
  3. package/out/cjs/yo-cli.cjs +1413 -592
  4. package/out/esm/index.mjs +434 -428
  5. package/out/types/src/build-runner.d.ts +1 -1
  6. package/out/types/src/doc/builder.d.ts +21 -0
  7. package/out/types/src/doc/builder.test.d.ts +1 -0
  8. package/out/types/src/doc/extractor.d.ts +27 -0
  9. package/out/types/src/doc/extractor.test.d.ts +1 -0
  10. package/out/types/src/doc/model.d.ts +87 -0
  11. package/out/types/src/doc/render-html.d.ts +23 -0
  12. package/out/types/src/doc/render-html.test.d.ts +1 -0
  13. package/out/types/src/doc/render-json.d.ts +7 -0
  14. package/out/types/src/doc/render-json.test.d.ts +1 -0
  15. package/out/types/src/doc/render-markdown.d.ts +13 -0
  16. package/out/types/src/doc/render-markdown.test.d.ts +1 -0
  17. package/out/types/src/doc/sections.d.ts +7 -0
  18. package/out/types/src/doc/sections.test.d.ts +1 -0
  19. package/out/types/src/doc-command.d.ts +10 -0
  20. package/out/types/src/env.d.ts +1 -0
  21. package/out/types/src/evaluator/builtins/build.d.ts +17 -0
  22. package/out/types/src/evaluator/context.d.ts +1 -0
  23. package/out/types/src/expr.d.ts +2 -1
  24. package/out/types/src/token.d.ts +4 -0
  25. package/out/types/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +2 -1
  27. package/scripts/build-site.ts +461 -0
  28. package/std/alg/hash.yo +12 -24
  29. package/std/allocator.yo +21 -29
  30. package/std/async.yo +4 -2
  31. package/std/build.yo +188 -42
  32. package/std/cli/arg_parser.yo +37 -1
  33. package/std/collections/array_list.yo +8 -20
  34. package/std/collections/btree_map.yo +15 -20
  35. package/std/collections/deque.yo +13 -15
  36. package/std/collections/hash_map.yo +15 -54
  37. package/std/collections/hash_set.yo +14 -50
  38. package/std/collections/linked_list.yo +6 -23
  39. package/std/collections/priority_queue.yo +15 -17
  40. package/std/crypto/md5.yo +10 -9
  41. package/std/crypto/random.yo +14 -12
  42. package/std/crypto/sha256.yo +9 -8
  43. package/std/encoding/base64.yo +13 -15
  44. package/std/encoding/hex.yo +14 -10
  45. package/std/encoding/html.yo +14 -11
  46. package/std/encoding/html_char_utils.yo +14 -11
  47. package/std/encoding/html_entities.yo +7 -8
  48. package/std/encoding/json.yo +36 -19
  49. package/std/encoding/punycode.yo +21 -18
  50. package/std/encoding/toml.yo +23 -9
  51. package/std/encoding/utf16.yo +16 -9
  52. package/std/error.yo +10 -23
  53. package/std/fmt/display.yo +15 -17
  54. package/std/fmt/index.yo +6 -27
  55. package/std/fmt/to_string.yo +4 -10
  56. package/std/fmt/writer.yo +33 -34
  57. package/std/fs/dir.yo +37 -30
  58. package/std/fs/file.yo +77 -75
  59. package/std/fs/metadata.yo +25 -25
  60. package/std/fs/temp.yo +21 -27
  61. package/std/fs/types.yo +20 -23
  62. package/std/fs/walker.yo +26 -31
  63. package/std/gc.yo +5 -0
  64. package/std/glob/index.yo +3 -0
  65. package/std/http/client.yo +25 -11
  66. package/std/http/http.yo +20 -0
  67. package/std/http/index.yo +1 -0
  68. package/std/io/reader.yo +4 -8
  69. package/std/io/writer.yo +4 -7
  70. package/std/libc/assert.yo +2 -2
  71. package/std/libc/ctype.yo +1 -2
  72. package/std/libc/dirent.yo +1 -2
  73. package/std/libc/errno.yo +1 -2
  74. package/std/libc/fcntl.yo +2 -2
  75. package/std/libc/float.yo +1 -2
  76. package/std/libc/limits.yo +1 -2
  77. package/std/libc/math.yo +2 -0
  78. package/std/libc/signal.yo +1 -2
  79. package/std/libc/stdatomic.yo +1 -2
  80. package/std/libc/stdint.yo +4 -3
  81. package/std/libc/stdio.yo +2 -0
  82. package/std/libc/stdlib.yo +2 -0
  83. package/std/libc/string.yo +2 -0
  84. package/std/libc/sys/stat.yo +1 -2
  85. package/std/libc/time.yo +2 -2
  86. package/std/libc/unistd.yo +2 -0
  87. package/std/libc/wctype.yo +1 -2
  88. package/std/libc/windows.yo +2 -2
  89. package/std/log/index.yo +11 -26
  90. package/std/net/addr.yo +18 -11
  91. package/std/net/dns.yo +3 -2
  92. package/std/net/errors.yo +16 -2
  93. package/std/net/tcp.yo +25 -22
  94. package/std/net/udp.yo +14 -12
  95. package/std/os/env.yo +23 -18
  96. package/std/os/signal.yo +31 -19
  97. package/std/path.yo +23 -74
  98. package/std/prelude.yo +284 -113
  99. package/std/process.yo +23 -37
  100. package/std/regex/compiler.yo +3 -5
  101. package/std/regex/flags.yo +11 -11
  102. package/std/regex/index.yo +2 -13
  103. package/std/regex/match.yo +3 -5
  104. package/std/regex/node.yo +6 -6
  105. package/std/regex/parser.yo +2 -4
  106. package/std/regex/unicode.yo +5 -5
  107. package/std/regex/vm.yo +5 -5
  108. package/std/string/index.yo +2 -1
  109. package/std/string/rune.yo +25 -1
  110. package/std/string/string.yo +31 -19
  111. package/std/string/unicode.yo +14 -15
  112. package/std/sync/channel.yo +18 -28
  113. package/std/sync/cond.yo +4 -0
  114. package/std/sync/mutex.yo +4 -1
  115. package/std/sync/once.yo +17 -19
  116. package/std/sync/rwlock.yo +19 -22
  117. package/std/sync/waitgroup.yo +21 -23
  118. package/std/sys/advise.yo +4 -4
  119. package/std/sys/bufio/buf_reader.yo +19 -16
  120. package/std/sys/bufio/buf_writer.yo +14 -11
  121. package/std/sys/clock.yo +4 -4
  122. package/std/sys/constants.yo +5 -5
  123. package/std/sys/copy.yo +9 -8
  124. package/std/sys/dir.yo +9 -8
  125. package/std/sys/dns.yo +8 -8
  126. package/std/sys/errors.yo +35 -6
  127. package/std/sys/events.yo +3 -3
  128. package/std/sys/externs.yo +3 -3
  129. package/std/sys/fallocate.yo +4 -4
  130. package/std/sys/fcntl.yo +8 -6
  131. package/std/sys/file.yo +7 -8
  132. package/std/sys/future.yo +1 -3
  133. package/std/sys/iov.yo +4 -4
  134. package/std/sys/lock.yo +7 -7
  135. package/std/sys/mmap.yo +7 -8
  136. package/std/sys/path.yo +4 -7
  137. package/std/sys/perm.yo +8 -8
  138. package/std/sys/pipe.yo +9 -8
  139. package/std/sys/process.yo +8 -8
  140. package/std/sys/seek.yo +4 -4
  141. package/std/sys/signal.yo +4 -4
  142. package/std/sys/signals.yo +4 -4
  143. package/std/sys/socket.yo +4 -4
  144. package/std/sys/socketpair.yo +4 -4
  145. package/std/sys/sockinfo.yo +4 -4
  146. package/std/sys/statfs.yo +8 -8
  147. package/std/sys/statx.yo +4 -4
  148. package/std/sys/sysinfo.yo +4 -4
  149. package/std/sys/tcp.yo +8 -8
  150. package/std/sys/temp.yo +9 -8
  151. package/std/sys/time.yo +8 -8
  152. package/std/sys/timer.yo +7 -8
  153. package/std/sys/tty.yo +13 -10
  154. package/std/sys/udp.yo +8 -8
  155. package/std/sys/umask.yo +4 -4
  156. package/std/sys/unix.yo +5 -5
  157. package/std/testing/bench.yo +21 -10
  158. package/std/thread.yo +18 -9
  159. package/std/time/datetime.yo +12 -14
  160. package/std/time/duration.yo +12 -14
  161. package/std/time/instant.yo +13 -16
  162. package/std/time/sleep.yo +9 -8
  163. package/std/url/index.yo +3 -19
  164. package/std/worker.yo +10 -18
@@ -16,7 +16,7 @@ export declare function stageRuntimeFiles(runtimeFiles: readonly string[], outpu
16
16
  export declare function runBuild(options: BuildOptions): Promise<void>;
17
17
  export interface DAGNode {
18
18
  name: string;
19
- kind: "artifact" | "test" | "run" | "step";
19
+ kind: "artifact" | "test" | "run" | "step" | "doc";
20
20
  dependsOn: string[];
21
21
  }
22
22
  export declare function buildDAG(registry: BuildRegistry, rootStepName: string): DAGNode[];
@@ -0,0 +1,21 @@
1
+ import type { Token } from "../token";
2
+ import type { ModuleValue } from "../value";
3
+ import type { DocExtractionResult } from "./extractor";
4
+ import type { DocModule } from "./model";
5
+ export interface BuildDocModuleOptions {
6
+ name: string;
7
+ path: string;
8
+ moduleValue: ModuleValue;
9
+ extraction: DocExtractionResult;
10
+ tokens: Token[];
11
+ includePrivate?: boolean;
12
+ }
13
+ export declare function buildDocModule(options: BuildDocModuleOptions): DocModule;
14
+ export interface BuildDocModuleFromTokensOptions {
15
+ name: string;
16
+ path: string;
17
+ extraction: DocExtractionResult;
18
+ tokens: Token[];
19
+ }
20
+ export declare function buildDocModuleFromTokens(options: BuildDocModuleFromTokensOptions): DocModule;
21
+ export declare function buildCrossReferences(modules: DocModule[]): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { Token } from "../token";
2
+ export interface DocComment {
3
+ content: string;
4
+ inner: boolean;
5
+ position: Token["position"];
6
+ modulePath: string;
7
+ }
8
+ export interface DocAssociation {
9
+ comment: DocComment;
10
+ declarationName: string;
11
+ declarationPosition: Token["position"] | null;
12
+ }
13
+ export interface DocExtractionResult {
14
+ moduleDoc: DocComment | null;
15
+ declarations: DocAssociation[];
16
+ }
17
+ export interface InlineDocResult {
18
+ docs: Map<string, string>;
19
+ }
20
+ export declare function stripDocLineComment(value: string): string;
21
+ export declare function stripDocBlockComment(value: string): string;
22
+ export declare function extractDocComments(tokens: Token[]): DocExtractionResult;
23
+ export declare function extractInlineDocs(tokens: Token[], startIndex: number, endIndex: number): InlineDocResult;
24
+ export declare function findMatchingParens(tokens: Token[], searchStart: number): {
25
+ open: number;
26
+ close: number;
27
+ } | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ export type DocItemKind = "function" | "struct" | "object" | "enum" | "newtype" | "union" | "trait" | "module" | "constant" | "type-alias" | "type-function";
2
+ export interface DocParam {
3
+ name: string;
4
+ type: string;
5
+ isComptime: boolean;
6
+ isImplicit: boolean;
7
+ defaultValue?: string;
8
+ doc?: string;
9
+ }
10
+ export interface DocField {
11
+ name: string;
12
+ type: string;
13
+ doc?: string;
14
+ defaultValue?: string;
15
+ }
16
+ export interface DocVariant {
17
+ name: string;
18
+ fields?: DocField[];
19
+ doc?: string;
20
+ discriminant?: string;
21
+ }
22
+ export interface DocAssociatedType {
23
+ name: string;
24
+ doc?: string;
25
+ constraint?: string;
26
+ }
27
+ export interface DocFunction {
28
+ name: string;
29
+ doc?: string;
30
+ signature: string;
31
+ parameters: DocParam[];
32
+ returnType: string;
33
+ typeParams?: DocParam[];
34
+ effects?: DocParam[];
35
+ isMethod: boolean;
36
+ selfType?: string;
37
+ returns?: string;
38
+ errors?: string;
39
+ deprecated?: string;
40
+ examples?: string;
41
+ }
42
+ export interface DocType {
43
+ name: string;
44
+ doc?: string;
45
+ kind: DocItemKind;
46
+ signature: string;
47
+ typeParams?: DocParam[];
48
+ fields?: DocField[];
49
+ variants?: DocVariant[];
50
+ methods: DocFunction[];
51
+ traitImpls: string[];
52
+ deprecated?: string;
53
+ examples?: string;
54
+ }
55
+ export interface DocTrait {
56
+ name: string;
57
+ doc?: string;
58
+ kind: "trait" | "module" | "trait-function" | "module-function";
59
+ signature: string;
60
+ typeParams?: DocParam[];
61
+ associatedTypes?: DocAssociatedType[];
62
+ methods: DocFunction[];
63
+ implementors: string[];
64
+ deprecated?: string;
65
+ examples?: string;
66
+ }
67
+ export interface DocConstant {
68
+ name: string;
69
+ doc?: string;
70
+ type: string;
71
+ value?: string;
72
+ deprecated?: string;
73
+ }
74
+ export interface DocModule {
75
+ name: string;
76
+ path: string;
77
+ doc?: string;
78
+ functions: DocFunction[];
79
+ types: DocType[];
80
+ traits: DocTrait[];
81
+ constants: DocConstant[];
82
+ submodules: DocModule[];
83
+ }
84
+ export interface DocModel {
85
+ name: string;
86
+ modules: DocModule[];
87
+ }
@@ -0,0 +1,23 @@
1
+ import type { DocModel } from "./model";
2
+ export declare function destroyMarkdownRenderer(): void;
3
+ declare function escapeHtml(text: string): string;
4
+ declare function moduleToFilename(name: string): string;
5
+ declare function moduleDisplayName(name: string): string;
6
+ declare function moduleGroup(name: string): string;
7
+ declare function generateCSS(): string;
8
+ declare function generateSearchJS(): string;
9
+ interface SearchEntry {
10
+ name: string;
11
+ kind: string;
12
+ href: string;
13
+ doc?: string;
14
+ module: string;
15
+ }
16
+ declare function buildSearchIndex(model: DocModel): SearchEntry[];
17
+ declare function firstSentence(text: string): string;
18
+ export interface RenderHtmlOptions {
19
+ model: DocModel;
20
+ outputDir: string;
21
+ }
22
+ export declare function renderDocSite(options: RenderHtmlOptions): Promise<void>;
23
+ export { escapeHtml, buildSearchIndex, firstSentence, generateCSS, generateSearchJS, moduleToFilename, moduleDisplayName, moduleGroup, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { DocModel } from "./model";
2
+ export interface RenderJsonOptions {
3
+ model: DocModel;
4
+ outputDir: string;
5
+ pretty?: boolean;
6
+ }
7
+ export declare function renderDocJson(options: RenderJsonOptions): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { DocModel, DocModule, DocFunction, DocType, DocTrait, DocConstant } from "./model";
2
+ declare function renderFunction(fn: DocFunction): string;
3
+ declare function renderType(type: DocType): string;
4
+ declare function renderTrait(trait: DocTrait): string;
5
+ declare function renderConstant(constant: DocConstant): string;
6
+ declare function renderModule(mod: DocModule): string;
7
+ declare function renderIndex(model: DocModel): string;
8
+ export interface RenderMarkdownOptions {
9
+ model: DocModel;
10
+ outputDir: string;
11
+ }
12
+ export declare function renderDocMarkdown(options: RenderMarkdownOptions): void;
13
+ export { renderFunction as renderFunctionMd, renderType as renderTypeMd, renderTrait as renderTraitMd, renderConstant as renderConstantMd, renderModule as renderModuleMd, renderIndex as renderIndexMd, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface ParsedDocComment {
2
+ summary: string;
3
+ description: string;
4
+ sections: Map<string, string>;
5
+ }
6
+ export declare function parseDocComment(text: string): ParsedDocComment;
7
+ export declare function isKnownSection(name: string): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export type DocFormat = "html" | "markdown" | "json";
2
+ export interface DocCommandOptions {
3
+ input: string;
4
+ outputDir: string;
5
+ includePrivate: boolean;
6
+ verbose: boolean;
7
+ title?: string;
8
+ format?: DocFormat;
9
+ }
10
+ export declare function runDoc(options: DocCommandOptions): Promise<void>;
@@ -21,6 +21,7 @@ export interface Variable {
21
21
  isFromEffectSpread?: boolean;
22
22
  isEffectParam?: boolean;
23
23
  isModuleLevel?: boolean;
24
+ docComment?: string;
24
25
  }
25
26
  export type WhereClauseConstraints = {
26
27
  someType: SomeType;
@@ -73,6 +73,17 @@ export interface ImportedModule {
73
73
  resolvedRoot?: string;
74
74
  propagatedSystemLibraries?: string[];
75
75
  }
76
+ export interface BuildDocConfig {
77
+ name: string;
78
+ root: string;
79
+ outputDir: string;
80
+ format: string;
81
+ includePrivate: boolean;
82
+ includeDeps: boolean;
83
+ title: string;
84
+ logo: string;
85
+ favicon: string;
86
+ }
76
87
  export declare class BuildRegistry {
77
88
  artifacts: BuildArtifact[];
78
89
  testSuites: BuildTestSuite[];
@@ -83,6 +94,7 @@ export declare class BuildRegistry {
83
94
  systemLibraries: BuildSystemLibrary[];
84
95
  dependencyArtifacts: DependencyArtifactRef[];
85
96
  modules: BuildModuleEntry[];
97
+ docConfigs: BuildDocConfig[];
86
98
  cliOptions: Map<string, string>;
87
99
  declaredOptions: Map<string, {
88
100
  description: string;
@@ -109,6 +121,8 @@ export declare class BuildRegistry {
109
121
  findTest(name: string): BuildTestSuite | undefined;
110
122
  findRunStep(name: string): BuildRunStep | undefined;
111
123
  findStep(name: string): BuildStep | undefined;
124
+ findDocumentation(name: string): BuildDocConfig | undefined;
125
+ registerDocumentation(config: BuildDocConfig): void;
112
126
  private checkDuplicateArtifactName;
113
127
  findDependency(name: string): BuildGitDependency | undefined;
114
128
  findPathDependency(name: string): BuildPathDependency | undefined;
@@ -123,6 +137,9 @@ export declare class BuildRegistry {
123
137
  } | {
124
138
  kind: "run";
125
139
  value: BuildRunStep;
140
+ } | {
141
+ kind: "doc";
142
+ value: BuildDocConfig;
126
143
  } | {
127
144
  kind: "step";
128
145
  value: BuildStep;
@@ -69,6 +69,7 @@ export interface EvaluatorContext {
69
69
  isInsideIoAsyncCall?: boolean;
70
70
  isInsideGivenHandler?: boolean;
71
71
  isEvaluatingGenericImplSpecialization?: boolean;
72
+ docCommentLookup?: Map<string, string>;
72
73
  }
73
74
  export interface ArgValues {
74
75
  forallArgs: {
@@ -64,7 +64,7 @@ export interface EvaluatedExprData {
64
64
  caseExecuted?: boolean;
65
65
  isPrimitiveMatch?: boolean;
66
66
  primitivePatternValues?: (Value | undefined)[];
67
- comment?: string;
67
+ docComment?: string;
68
68
  deferredDupExpressions?: Expr[];
69
69
  deferredDropExpressions?: Expr[];
70
70
  consumedVariableDropExpressions?: Expr[];
@@ -600,6 +600,7 @@ export declare const BuiltinFunctions: {
600
600
  __yo_build_add_import: string[];
601
601
  __yo_build_add_cflags: string[];
602
602
  __yo_build_dep_module: string[];
603
+ __yo_build_doc: string[];
603
604
  asm: string[];
604
605
  global_asm: string[];
605
606
  };
@@ -17,6 +17,10 @@ export declare enum TokenType {
17
17
  Comma = ",",
18
18
  SingleLineComment = "single_line_comment",
19
19
  MultiLineComment = "multi_line_comment",
20
+ DocLineComment = "doc_line_comment",
21
+ InnerDocLineComment = "inner_doc_line_comment",
22
+ DocBlockComment = "doc_block_comment",
23
+ InnerDocBlockComment = "inner_doc_block_comment",
20
24
  Whitespace = "whitespace",
21
25
  TemplateString = "template_string"
22
26
  }