@appium/docutils 0.1.6 → 0.2.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 (214) hide show
  1. package/README.md +2 -5
  2. package/build/lib/build/mkdocs.d.ts +58 -0
  3. package/build/lib/build/mkdocs.d.ts.map +1 -0
  4. package/build/lib/build/mkdocs.js +80 -0
  5. package/build/lib/build/mkdocs.js.map +1 -0
  6. package/build/lib/build/typedoc.d.ts +55 -0
  7. package/build/lib/build/typedoc.d.ts.map +1 -0
  8. package/build/lib/build/typedoc.js +120 -0
  9. package/build/lib/build/typedoc.js.map +1 -0
  10. package/build/lib/build-api.d.ts +18 -0
  11. package/build/lib/build-api.d.ts.map +1 -0
  12. package/build/lib/build-api.js +75 -0
  13. package/build/lib/build-api.js.map +1 -0
  14. package/build/lib/build.d.ts +21 -0
  15. package/build/lib/build.d.ts.map +1 -0
  16. package/build/lib/build.js +71 -0
  17. package/build/lib/build.js.map +1 -0
  18. package/build/lib/builder/deploy.d.ts +89 -0
  19. package/build/lib/builder/deploy.d.ts.map +1 -0
  20. package/build/lib/builder/deploy.js +102 -0
  21. package/build/lib/builder/deploy.js.map +1 -0
  22. package/build/lib/builder/index.d.ts +5 -0
  23. package/build/lib/builder/index.d.ts.map +1 -0
  24. package/build/lib/builder/index.js +21 -0
  25. package/build/lib/builder/index.js.map +1 -0
  26. package/build/lib/builder/nav.d.ts +81 -0
  27. package/build/lib/builder/nav.d.ts.map +1 -0
  28. package/build/lib/builder/nav.js +272 -0
  29. package/build/lib/builder/nav.js.map +1 -0
  30. package/build/lib/builder/reference.d.ts +57 -0
  31. package/build/lib/builder/reference.d.ts.map +1 -0
  32. package/build/lib/builder/reference.js +129 -0
  33. package/build/lib/builder/reference.js.map +1 -0
  34. package/build/lib/builder/site.d.ts +55 -0
  35. package/build/lib/builder/site.d.ts.map +1 -0
  36. package/build/lib/builder/site.js +81 -0
  37. package/build/lib/builder/site.js.map +1 -0
  38. package/build/lib/cli/command/build.d.ts +178 -0
  39. package/build/lib/cli/command/build.d.ts.map +1 -0
  40. package/build/lib/cli/command/build.js +223 -0
  41. package/build/lib/cli/command/build.js.map +1 -0
  42. package/build/lib/cli/command/deploy.d.ts +1 -0
  43. package/build/lib/cli/command/deploy.d.ts.map +1 -0
  44. package/build/lib/cli/command/deploy.js +2 -0
  45. package/build/lib/cli/command/deploy.js.map +1 -0
  46. package/build/lib/cli/command/index.d.ts +4 -0
  47. package/build/lib/cli/command/index.d.ts.map +1 -0
  48. package/build/lib/cli/command/index.js +13 -0
  49. package/build/lib/cli/command/index.js.map +1 -0
  50. package/build/lib/cli/command/init.d.ts +143 -0
  51. package/build/lib/cli/command/init.d.ts.map +1 -0
  52. package/build/lib/cli/command/init.js +164 -0
  53. package/build/lib/cli/command/init.js.map +1 -0
  54. package/build/lib/cli/command/validate.d.ts +76 -0
  55. package/build/lib/cli/command/validate.d.ts.map +1 -0
  56. package/build/lib/cli/command/validate.js +115 -0
  57. package/build/lib/cli/command/validate.js.map +1 -0
  58. package/build/lib/cli/command-init.d.ts +143 -0
  59. package/build/lib/cli/command-init.d.ts.map +1 -0
  60. package/build/lib/cli/command-init.js +164 -0
  61. package/build/lib/cli/command-init.js.map +1 -0
  62. package/build/lib/cli/command-validate.d.ts +52 -0
  63. package/build/lib/cli/command-validate.d.ts.map +1 -0
  64. package/build/lib/cli/command-validate.js +66 -0
  65. package/build/lib/cli/command-validate.js.map +1 -0
  66. package/build/lib/cli/config.d.ts +28 -0
  67. package/build/lib/cli/config.d.ts.map +1 -0
  68. package/build/lib/cli/config.js +114 -0
  69. package/build/lib/cli/config.js.map +1 -0
  70. package/build/lib/cli/index.d.ts +13 -0
  71. package/build/lib/cli/index.d.ts.map +1 -0
  72. package/build/lib/cli/index.js +91 -0
  73. package/build/lib/cli/index.js.map +1 -0
  74. package/build/lib/cli/init.d.ts +143 -0
  75. package/build/lib/cli/init.d.ts.map +1 -0
  76. package/build/lib/cli/init.js +164 -0
  77. package/build/lib/cli/init.js.map +1 -0
  78. package/build/lib/cli/options.d.ts +1 -0
  79. package/build/lib/cli/options.d.ts.map +1 -0
  80. package/build/lib/cli/options.js +2 -0
  81. package/build/lib/cli/options.js.map +1 -0
  82. package/build/lib/cli/validate.d.ts +1 -0
  83. package/build/lib/cli/validate.d.ts.map +1 -0
  84. package/build/lib/cli/validate.js +2 -0
  85. package/build/lib/cli/validate.js.map +1 -0
  86. package/build/lib/cli.d.ts +10 -0
  87. package/build/lib/cli.d.ts.map +1 -0
  88. package/build/lib/cli.js +328 -0
  89. package/build/lib/cli.js.map +1 -0
  90. package/build/lib/constants.d.ts +125 -0
  91. package/build/lib/constants.d.ts.map +1 -0
  92. package/build/lib/constants.js +133 -0
  93. package/build/lib/constants.js.map +1 -0
  94. package/build/lib/error.d.ts +3 -0
  95. package/build/lib/error.d.ts.map +1 -0
  96. package/build/lib/error.js +7 -0
  97. package/build/lib/error.js.map +1 -0
  98. package/build/lib/fs.d.ts +142 -0
  99. package/build/lib/fs.d.ts.map +1 -0
  100. package/build/lib/fs.js +237 -0
  101. package/build/lib/fs.js.map +1 -0
  102. package/build/lib/index.d.ts +5 -2
  103. package/build/lib/index.d.ts.map +1 -1
  104. package/build/lib/index.js +4 -1
  105. package/build/lib/index.js.map +1 -1
  106. package/build/lib/init-task.d.ts +49 -0
  107. package/build/lib/init-task.d.ts.map +1 -0
  108. package/build/lib/init-task.js +95 -0
  109. package/build/lib/init-task.js.map +1 -0
  110. package/build/lib/init.d.ts +202 -0
  111. package/build/lib/init.d.ts.map +1 -0
  112. package/build/lib/init.js +225 -0
  113. package/build/lib/init.js.map +1 -0
  114. package/build/lib/io.d.ts +1 -0
  115. package/build/lib/io.d.ts.map +1 -0
  116. package/build/lib/io.js +2 -0
  117. package/build/lib/io.js.map +1 -0
  118. package/build/lib/logger.d.ts +17 -2
  119. package/build/lib/logger.d.ts.map +1 -1
  120. package/build/lib/logger.js +187 -2
  121. package/build/lib/logger.js.map +1 -1
  122. package/build/lib/mike.d.ts +3 -0
  123. package/build/lib/mike.d.ts.map +1 -1
  124. package/build/lib/mike.js +4 -0
  125. package/build/lib/mike.js.map +1 -1
  126. package/build/lib/mkdocs.d.ts +51 -12
  127. package/build/lib/mkdocs.d.ts.map +1 -1
  128. package/build/lib/mkdocs.js +64 -32
  129. package/build/lib/mkdocs.js.map +1 -1
  130. package/build/lib/model.d.ts +80 -0
  131. package/build/lib/model.d.ts.map +1 -0
  132. package/build/lib/model.js +8 -0
  133. package/build/lib/model.js.map +1 -0
  134. package/build/lib/nav.d.ts +47 -0
  135. package/build/lib/nav.d.ts.map +1 -0
  136. package/build/lib/nav.js +132 -0
  137. package/build/lib/nav.js.map +1 -0
  138. package/build/lib/scaffold.d.ts +95 -0
  139. package/build/lib/scaffold.d.ts.map +1 -0
  140. package/build/lib/scaffold.js +103 -0
  141. package/build/lib/scaffold.js.map +1 -0
  142. package/build/lib/test.d.ts +9 -0
  143. package/build/lib/test.d.ts.map +1 -0
  144. package/build/lib/test.js +2 -0
  145. package/build/lib/test.js.map +1 -0
  146. package/build/lib/typedoc.d.ts +55 -0
  147. package/build/lib/typedoc.d.ts.map +1 -0
  148. package/build/lib/typedoc.js +122 -0
  149. package/build/lib/typedoc.js.map +1 -0
  150. package/build/lib/types.d.ts +52 -0
  151. package/build/lib/types.d.ts.map +1 -0
  152. package/build/lib/types.js +7 -0
  153. package/build/lib/types.js.map +1 -0
  154. package/build/lib/util.d.ts +42 -0
  155. package/build/lib/util.d.ts.map +1 -0
  156. package/build/lib/util.js +56 -0
  157. package/build/lib/util.js.map +1 -0
  158. package/build/lib/validate.d.ts +218 -0
  159. package/build/lib/validate.d.ts.map +1 -0
  160. package/build/lib/validate.js +501 -0
  161. package/build/lib/validate.js.map +1 -0
  162. package/build/lib/validation/base-validator.d.ts +218 -0
  163. package/build/lib/validation/base-validator.d.ts.map +1 -0
  164. package/build/lib/validation/base-validator.js +453 -0
  165. package/build/lib/validation/base-validator.js.map +1 -0
  166. package/build/lib/validation/mkdocs-validator.d.ts +5 -0
  167. package/build/lib/validation/mkdocs-validator.d.ts.map +1 -0
  168. package/build/lib/validation/mkdocs-validator.js +54 -0
  169. package/build/lib/validation/mkdocs-validator.js.map +1 -0
  170. package/build/lib/validation/python-validator.d.ts +1 -0
  171. package/build/lib/validation/python-validator.d.ts.map +1 -0
  172. package/build/lib/validation/python-validator.js +2 -0
  173. package/build/lib/validation/python-validator.js.map +1 -0
  174. package/build/lib/validation/python.d.ts +1 -0
  175. package/build/lib/validation/python.d.ts.map +1 -0
  176. package/build/lib/validation/python.js +2 -0
  177. package/build/lib/validation/python.js.map +1 -0
  178. package/build/lib/validation/validate.d.ts +221 -0
  179. package/build/lib/validation/validate.d.ts.map +1 -0
  180. package/build/lib/validation/validate.js +508 -0
  181. package/build/lib/validation/validate.js.map +1 -0
  182. package/build/lib/validation/validator.d.ts +220 -0
  183. package/build/lib/validation/validator.d.ts.map +1 -0
  184. package/build/lib/validation/validator.js +470 -0
  185. package/build/lib/validation/validator.js.map +1 -0
  186. package/lib/builder/deploy.ts +217 -0
  187. package/lib/builder/index.ts +4 -0
  188. package/lib/builder/nav.ts +393 -0
  189. package/lib/builder/reference.ts +191 -0
  190. package/lib/builder/site.ts +143 -0
  191. package/lib/cli/command/build.ts +229 -0
  192. package/lib/cli/command/index.ts +3 -0
  193. package/lib/cli/command/init.ts +166 -0
  194. package/lib/cli/command/validate.ts +122 -0
  195. package/lib/cli/config.ts +89 -0
  196. package/lib/cli/index.ts +88 -0
  197. package/lib/constants.ts +150 -0
  198. package/lib/error.ts +1 -0
  199. package/lib/fs.ts +274 -0
  200. package/lib/index.ts +5 -0
  201. package/lib/init.ts +319 -0
  202. package/lib/logger.ts +198 -0
  203. package/lib/mike.js +4 -0
  204. package/lib/model.ts +92 -0
  205. package/lib/scaffold.ts +225 -0
  206. package/lib/util.ts +76 -0
  207. package/lib/validate.ts +728 -0
  208. package/package.json +38 -6
  209. package/requirements.txt +4 -0
  210. package/tsconfig.json +2 -1
  211. package/build/tsconfig.tsbuildinfo +0 -1
  212. package/lib/index.js +0 -2
  213. package/lib/logger.js +0 -3
  214. package/lib/mkdocs.js +0 -43
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../lib/validation/validator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,6CAAmC;AACnC,kDAA0B;AAC1B,oDAAuB;AACvB,6CAAyC;AACzC,0DAA6B;AAC7B,0DAAkC;AAClC,mCAAiC;AACjC,+CAAkC;AAClC,4CAiBsB;AACtB,oCAAuC;AACvC,8BASe;AACf,uDAA+B;AAE/B,kCAAiC;AAEjC;;GAEG;AACH,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC;;GAEG;AACH,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D;;GAEG;AACH,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAExD,MAAM,GAAG,GAAG,gBAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAYvC;;;;;;;;GAQG;AACH,MAAa,iBAAkB,SAAQ,0BAAY;IA0EjD;;OAEG;IACH,YAAY,OAAuC,EAAE;QACnD,KAAK,EAAE,CAAC;QA9DV;;WAEG;QACgB,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE5D;;;;;;;WAOG;QACO,kBAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;QAmDzD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAC,CAAC,YAAY,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAC,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;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yBAAO,GAAG,IAAI,CAAC"}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Functions for running `mike`
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import _ from 'lodash';
8
+ import {exec, SubProcess, TeenProcessExecOptions} from 'teen_process';
9
+ import path from 'node:path';
10
+ import {
11
+ DEFAULT_DEPLOY_BRANCH,
12
+ DEFAULT_DEPLOY_REMOTE,
13
+ DEFAULT_SERVE_HOST,
14
+ DEFAULT_SERVE_PORT,
15
+ NAME_BIN,
16
+ NAME_MKDOCS_YML,
17
+ } from '../constants';
18
+ import {DocutilsError} from '../error';
19
+ import {findMkDocsYml, readPackageJson, whichMike} from '../fs';
20
+ import logger from '../logger';
21
+ import {argify, stopwatch, TeenProcessSubprocessStartOpts} from '../util';
22
+
23
+ const log = logger.withTag('builder:deploy');
24
+
25
+ /**
26
+ * Runs `mike serve`
27
+ * @param args Extra args to `mike build`
28
+ * @param opts Extra options for `teen_process.Subprocess.start`
29
+ * @param mikePath Path to `mike` executable
30
+ */
31
+ async function doServe(
32
+ args: string[] = [],
33
+ {startDetector, detach, timeoutMs}: TeenProcessSubprocessStartOpts = {},
34
+ mikePath?: string
35
+ ) {
36
+ mikePath = mikePath ?? (await whichMike());
37
+ const finalArgs = ['serve', ...args];
38
+ log.debug('Launching %s with args: %O', mikePath, finalArgs);
39
+ const proc = new SubProcess(mikePath, finalArgs);
40
+ return await proc.start(startDetector, detach, timeoutMs);
41
+ }
42
+
43
+ /**
44
+ * Runs `mike build`
45
+ * @param args Extra args to `mike build`
46
+ * @param opts Extra options to `teen_process.exec`
47
+ * @param mikePath Path to `mike` executable
48
+ */
49
+ async function doDeploy(args: string[] = [], opts: TeenProcessExecOptions = {}, mikePath?: string) {
50
+ mikePath = mikePath ?? (await whichMike());
51
+ const finalArgs = ['deploy', ...args];
52
+ log.debug('Launching %s with args: %O', mikePath, finalArgs);
53
+ return await exec(mikePath, finalArgs, opts);
54
+ }
55
+
56
+ /**
57
+ * Derives a deployment version from `package.json`
58
+ * @param packageJsonPath Path to `package.json` if known
59
+ * @param cwd Current working directory
60
+ */
61
+ async function findDeployVersion(packageJsonPath?: string, cwd = process.cwd()): Promise<string> {
62
+ const {pkg} = await readPackageJson(packageJsonPath ? path.dirname(packageJsonPath) : cwd, true);
63
+ const version = pkg.version;
64
+ if (!version) {
65
+ throw new DocutilsError(
66
+ 'No "version" field found in package.json; please add one or specify a version to deploy'
67
+ );
68
+ }
69
+ return version;
70
+ }
71
+
72
+ /**
73
+ * Runs `mike build` or `mike serve`
74
+ * @param opts Options
75
+ */
76
+ export async function deploy({
77
+ mkDocsYml: mkDocsYmlPath,
78
+ packageJson: packageJsonPath,
79
+ deployVersion: version,
80
+ cwd = process.cwd(),
81
+ serve = false,
82
+ push = false,
83
+ branch = DEFAULT_DEPLOY_BRANCH,
84
+ remote = DEFAULT_DEPLOY_REMOTE,
85
+ prefix,
86
+ message,
87
+ alias,
88
+ rebase = true,
89
+ port = DEFAULT_SERVE_PORT,
90
+ host = DEFAULT_SERVE_HOST,
91
+ serveOpts,
92
+ execOpts,
93
+ }: DeployOpts = {}) {
94
+ const stop = stopwatch('deploy');
95
+ mkDocsYmlPath = mkDocsYmlPath ?? (await findMkDocsYml(cwd));
96
+ if (!mkDocsYmlPath) {
97
+ throw new DocutilsError(
98
+ `Could not find ${NAME_MKDOCS_YML} from ${cwd}; run "${NAME_BIN} init" to create it`
99
+ );
100
+ }
101
+ version = version ?? (await findDeployVersion(packageJsonPath, cwd));
102
+ const mikeOpts = {
103
+ 'config-file': mkDocsYmlPath,
104
+ push,
105
+ remote,
106
+ branch,
107
+ prefix,
108
+ message,
109
+ rebase,
110
+ port,
111
+ host,
112
+ };
113
+ if (serve) {
114
+ const mikeArgs = [...argify(_.pickBy(mikeOpts, Boolean)), version];
115
+ if (alias) {
116
+ mikeArgs.push(alias);
117
+ }
118
+ // unsure about how SIGHUP is handled here
119
+ await doServe(mikeArgs, serveOpts);
120
+ } else {
121
+ const mikeArgs = [
122
+ ...argify(
123
+ _.omitBy(mikeOpts, (value, key) => _.includes(['port', 'host'], key) || value === false)
124
+ ),
125
+ version,
126
+ ];
127
+ if (alias) {
128
+ mikeArgs.push(alias);
129
+ }
130
+ await doDeploy(mikeArgs, execOpts);
131
+
132
+ log.success('Mike finished deployment into branch %s (%dms)', branch, stop());
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Options for {@linkcode deploy}.
138
+ */
139
+ export interface DeployOpts {
140
+ /**
141
+ * Path to `mike.yml`
142
+ */
143
+ mkDocsYml?: string;
144
+
145
+ /**
146
+ * Current working directory
147
+ * @defaultValue `process.cwd()`
148
+ */
149
+ cwd?: string;
150
+
151
+ /**
152
+ * Path to `package.json`
153
+ *
154
+ * Used to find `mike.yml` if unspecified.
155
+ */
156
+ packageJson?: string;
157
+
158
+ /**
159
+ * If `true`, run `mike serve` instead of `mike build`
160
+ */
161
+ serve?: boolean;
162
+
163
+ /**
164
+ * If `true`, push `branch` to `remote`
165
+ */
166
+ push?: boolean;
167
+ /**
168
+ * Branch to commit to
169
+ * @defaultValue gh-pages
170
+ */
171
+ branch?: string;
172
+ /**
173
+ * Remote to push to
174
+ * @defaultValue origin
175
+ */
176
+ remote?: string;
177
+ /**
178
+ * Subdirectory within `branch` to deploy to
179
+ */
180
+ prefix?: string;
181
+ /**
182
+ * Commit message
183
+ */
184
+ message?: string;
185
+ /**
186
+ * Version (dir) to deploy build to
187
+ */
188
+ deployVersion?: string;
189
+ /**
190
+ * Alias for the build (e.g., `latest`); triggers alias update
191
+ */
192
+ alias?: string;
193
+ /**
194
+ * If `true`, rebase `branch` before pushing
195
+ */
196
+ rebase?: boolean;
197
+ /**
198
+ * Port to serve on
199
+ * @defaultValue 8000
200
+ */
201
+ port?: number;
202
+ /**
203
+ * Host to serve on
204
+ * @defaultValue localhost
205
+ */
206
+ host?: string;
207
+
208
+ /**
209
+ * Extra options for {@linkcode teen_process.exec}
210
+ */
211
+ execOpts?: TeenProcessExecOptions;
212
+
213
+ /**
214
+ * Extra options for {@linkcode teen_process.Subprocess.start}
215
+ */
216
+ serveOpts?: TeenProcessSubprocessStartOpts;
217
+ }
@@ -0,0 +1,4 @@
1
+ export * from './deploy';
2
+ export * from './site';
3
+ export * from './reference';
4
+ export * from './nav';
@@ -0,0 +1,393 @@
1
+ /**
2
+ * Handles updating/adding the `nav` property of `mkdocs.yml`, based on the output of `typedoc`;
3
+ * specifically, the command documentation generated by `@appium/typedoc-plugin-appium`.
4
+ *
5
+ * @module
6
+ */
7
+
8
+ import {fs} from '@appium/support';
9
+ import _ from 'lodash';
10
+ import path from 'node:path';
11
+ import {
12
+ DEFAULT_NAV_HEADER,
13
+ DEFAULT_REL_TYPEDOC_OUT_PATH,
14
+ NAME_BIN,
15
+ NAME_MKDOCS_YML,
16
+ NAME_TYPEDOC_JSON,
17
+ } from '../constants';
18
+ import {DocutilsError} from '../error';
19
+ import {
20
+ findDirsIn,
21
+ findMkDocsYml,
22
+ findTypeDocJsonPath,
23
+ readTypedocJson,
24
+ readYaml,
25
+ safeWriteFile,
26
+ stringifyYaml,
27
+ } from '../fs';
28
+ import logger from '../logger';
29
+ import {MkDocsYml, MkDocsYmlNav} from '../model';
30
+ import {relative} from '../util';
31
+
32
+ const log = logger.withTag('builder:nav');
33
+
34
+ /**
35
+ * Gets a list of `.md` files relative to `docs_dir`
36
+ * @param targetDir Directory ostensibly containing Markdown files; must be absolute
37
+ * @param mkDocsDocsDir The path to the `docs_dir` in the `mkdocs.yml` file; must be absolute
38
+ * @returns List of Markdown files relative to the `docs_dir` in the `mkdocs.yml` file
39
+ */
40
+ async function findRelativeMarkdownFiles(
41
+ targetDir: string,
42
+ mkDocsDocsDir: string
43
+ ): Promise<string[]> {
44
+ if (!path.isAbsolute(targetDir)) {
45
+ throw new DocutilsError(`Expected absolute path, got '${targetDir}'`);
46
+ }
47
+ if (!path.isAbsolute(mkDocsDocsDir)) {
48
+ throw new DocutilsError(`Expected absolute path, got '${mkDocsDocsDir}'`);
49
+ }
50
+ const relDir = path.relative(mkDocsDocsDir, targetDir);
51
+ const dirEnts = await fs.readdir(targetDir, {withFileTypes: true});
52
+ return dirEnts
53
+ .filter((ent) => ent.isFile() && ent.name.endsWith('.md'))
54
+ .map((ent) => path.join(relDir, ent.name));
55
+ }
56
+
57
+ /**
58
+ * Because the `nav` property of `mkdocs.yml` is both a recursive type and a kind of awful one, it's
59
+ * easier to work with it if we rewrite the data into a flat array of objects. We keep a `keypath`
60
+ * prop which represents the deep/nested location within the `nav` object.
61
+ *
62
+ * @privateRemarks This function is not recursive; instead it loops over a queue of items to process
63
+ * data, and we append to that queue while processing if needed.
64
+ * @param nav Contents of the `nav` prop of `mkdocs.yml`
65
+ * @returns A list of objects, each with a `keypath` property and a `fileOrUrl` property (and maybe
66
+ * a `name` property)
67
+ */
68
+ export function parseNav(nav: MkDocsYmlNav): ParsedNavData[] {
69
+ let parsedNav: ParsedNavData[] = [];
70
+ const entries = Object.entries(nav);
71
+ type QueueItem = {
72
+ entries: typeof entries;
73
+ keypath: string;
74
+ };
75
+ const queue: QueueItem[] = [{entries, keypath: ''}];
76
+
77
+ while (queue.length) {
78
+ const {entries, keypath} = queue.shift()!;
79
+ for (const [key, item] of entries) {
80
+ if (_.isString(item)) {
81
+ const navData: ParsedNavData = {
82
+ keypath: keypath ? `${keypath}.${key}` : key,
83
+ fileOrUrl: item,
84
+ };
85
+
86
+ // if the key is not convertible to a number, it's a name
87
+ // which was manually put there by somebody.
88
+ if (Number.isNaN(Number(key))) {
89
+ navData.name = key;
90
+ }
91
+ parsedNav = [...parsedNav, navData];
92
+ } else if (_.isObject(item)) {
93
+ const subEntries = Object.entries(item);
94
+ queue.push({entries: subEntries, keypath: keypath ? `${keypath}.${key}` : key});
95
+ }
96
+ }
97
+ }
98
+ return parsedNav;
99
+ }
100
+
101
+ /**
102
+ * Finds all items within the list of parsed nav data which correpsond to the header. This is
103
+ * imperfect, as it's possible for the header string to appear in multiple places in the nav, but let's just ignore that until we can't.
104
+ * @param navData Some parsed nav data
105
+ * @param header Header name
106
+ */
107
+ function filterHeaderItems(navData: ParsedNavData[], header: string) {
108
+ return _.filter(navData, (item) => _.toPath(item.keypath).includes(header));
109
+ }
110
+
111
+ /**
112
+ *
113
+ * @param rootHeaderKeypath Root keypath as determined by {@linkcode getRootHeaderKeypath}
114
+ * @param offset Numeric offset within the array of items for the header
115
+ * @param data Any parsed nav data found. For new items, this will be `undefined`. If not new, it
116
+ * may or may not have a `name` prop, and if it does, we want to retain it.
117
+ * @returns Complete keypath for a nav item beginning with the root keypath
118
+ */
119
+ function getKeypathForHeaderItem(rootHeaderKeypath: string, offset: number, data?: ParsedNavData) {
120
+ return data?.name
121
+ ? `${rootHeaderKeypath}.${offset}.${data.name}`
122
+ : `${rootHeaderKeypath}.${offset}`;
123
+ }
124
+
125
+ /**
126
+ * Compares two sets of nav data and determines if they are different.
127
+ *
128
+ * This does not compare the entire `nav` object with a new one; it works per-header
129
+ * @param newNavData Nav data as computed by {@linkcode getNavItemsForDir} corresponding to a
130
+ * particular header
131
+ * @param navData Subset of original nav data as parsed by {@linkcode parseNav}, corresponding to
132
+ * the same header
133
+ */
134
+ function navDataDidChange(
135
+ newNavData: Array<Omit<ParsedNavData, 'name'>>,
136
+ navData: ParsedNavData[]
137
+ ): boolean {
138
+ const diff = _.xorWith(
139
+ newNavData,
140
+ navData,
141
+ (a, b) => a.keypath === b.keypath && a.fileOrUrl === b.fileOrUrl
142
+ );
143
+ return !_.isEmpty(diff);
144
+ }
145
+
146
+ /**
147
+ * Find the "root" keypath for a particular header
148
+ * @param headerItems Some subset of the nav data having keypaths corresponding to `header`
149
+ * @param header Header string
150
+ * @returns The keypath up to the header string, inclusive
151
+ */
152
+ function getRootHeaderKeypath(headerItems: ParsedNavData[], header: string) {
153
+ // these are the parts of the keypath of the first item, which will contain the header string. it
154
+ // dosn't matter whether we pick the first one or any one; they will all contain the same root
155
+ // keypath by definition.
156
+ const rootHeaderKeypathParts = _.toPath(_.first(headerItems)!.keypath);
157
+
158
+ // this is the keypath up to the header string, inclusive.
159
+ // we append indices or names to this keypath
160
+ return rootHeaderKeypathParts.slice(0, rootHeaderKeypathParts.indexOf(header) + 1).join('.');
161
+ }
162
+
163
+ /**
164
+ * This examines the `navData` looking for items matching the header string (which _may_ be defined
165
+ * by `dir`; if `all` is true, we just use the default header, because we will be returning a whole
166
+ * lot of headers).
167
+ *
168
+ *
169
+ * @param dir Abs path to directory containing markdown files generated by TypeDoc
170
+ * @param mkDocsDocsDir Configured `docs_dir` or via options
171
+ * @param navData Nav data parsed by {@linkcode parseNav}
172
+ * @param all If `true`, process all markdown files, not just commands
173
+ * @returns
174
+ */
175
+ async function getNavItemsForDir(
176
+ dir: string,
177
+ mkDocsDocsDir: string,
178
+ navData: ParsedNavData[],
179
+ nav: MkDocsYmlNav,
180
+ all = false
181
+ ) {
182
+ let dataChanged = false;
183
+ const newHeaderItems: Omit<ParsedNavData, 'name'>[] = [];
184
+
185
+ const newRefFilepaths = await findRelativeMarkdownFiles(dir, mkDocsDocsDir);
186
+
187
+ const header = all ? _.startCase(path.basename(dir)) : DEFAULT_NAV_HEADER;
188
+
189
+ const headerItems = filterHeaderItems(navData, header);
190
+
191
+ // if we found items with this header already, we are going
192
+ // to replace them all wholesale
193
+ if (headerItems.length) {
194
+ // we append indices or names to this keypath
195
+ const rootHeaderKeypath = getRootHeaderKeypath(headerItems, header);
196
+
197
+ for (const [offset, fileOrUrl] of newRefFilepaths.entries()) {
198
+ const data = headerItems.find((item) => item.fileOrUrl === fileOrUrl);
199
+ const keypath = getKeypathForHeaderItem(rootHeaderKeypath, offset, data);
200
+ newHeaderItems.push({keypath, fileOrUrl});
201
+ }
202
+
203
+ // look for any differences between what we have and what's in the file
204
+ if (navDataDidChange(newHeaderItems, headerItems)) {
205
+ log.debug('Will write new nav data for header %s', header);
206
+ dataChanged = true;
207
+ } else {
208
+ log.debug('No changes for header %s', header);
209
+ }
210
+ } else {
211
+ let navOffset = nav.length;
212
+ for (const [idx, newRefFilepath] of newRefFilepaths.entries()) {
213
+ newHeaderItems.push({
214
+ keypath: `${navOffset}.${header}.${idx}`,
215
+ fileOrUrl: newRefFilepath,
216
+ });
217
+ }
218
+ log.debug('Will create nav data for header %s', header);
219
+ dataChanged = true;
220
+ }
221
+ return {data: newHeaderItems, changed: dataChanged};
222
+ }
223
+
224
+ /**
225
+ * Applies the changes in `newData` to the `mkDocsYml` object.
226
+ *
227
+ * **This function mutates `mkDocsYml`.**
228
+ * @param newData New nav data
229
+ * @param mkDocsYml Original `mkdocs.yml`
230
+ */
231
+ function applyNavData(newData: ParsedNavData[], mkDocsYml: MkDocsYml) {
232
+ for (const {keypath, fileOrUrl} of newData) {
233
+ _.set(mkDocsYml, `nav.${keypath}`, fileOrUrl);
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Update the `nav` property of `mkdocs.yml` with a list of "command" files generated by TypeDoc via
239
+ * `@appium/typedoc-plugin-appium`.
240
+ *
241
+ * To be clear, this function **modifies the MkDocs config file (`mkdocs.yml`) in place**; it is
242
+ * typically under version control, so if this function makes any changes, you'll want to commit them.
243
+ * @param opts - Options
244
+ * @todo implement `dryRun` option
245
+ */
246
+ export async function updateNav({
247
+ cwd = process.cwd(),
248
+ mkdocsYml: mkDocsYmlPath,
249
+ typedocJson: typeDocJsonPath,
250
+ all = false,
251
+ dryRun = false,
252
+ }: UpdateNavOpts = {}) {
253
+ // we need `mkdocs.yml` to update
254
+ // and we need `typedoc.json` to know where to look for the command docs
255
+ [mkDocsYmlPath, typeDocJsonPath] = await Promise.all([
256
+ mkDocsYmlPath ?? findMkDocsYml(cwd),
257
+ typeDocJsonPath ?? findTypeDocJsonPath(cwd),
258
+ ]);
259
+ if (!mkDocsYmlPath) {
260
+ throw new DocutilsError(
261
+ `Could not find ${NAME_MKDOCS_YML} from ${cwd}; run "${NAME_BIN} init" to create it`
262
+ );
263
+ }
264
+ if (!typeDocJsonPath) {
265
+ throw new DocutilsError(
266
+ `Could not find ${NAME_TYPEDOC_JSON} from ${cwd}; run "${NAME_BIN} init" to create it`
267
+ );
268
+ }
269
+ const relativePath = relative(cwd);
270
+ const relMkDocsYmlPath = relativePath(mkDocsYmlPath);
271
+ const typeDocJson = readTypedocJson(typeDocJsonPath);
272
+ const mkDocsYml = (await readYaml(mkDocsYmlPath)) as MkDocsYml;
273
+
274
+ /**
275
+ * Absolute path to `typedoc.json`
276
+ */
277
+ const absTypeDocJsonPath = path.isAbsolute(typeDocJsonPath)
278
+ ? typeDocJsonPath
279
+ : path.resolve(cwd, typeDocJsonPath);
280
+
281
+ /**
282
+ * Absolute path to TypeDoc's output directory (`out`)
283
+ */
284
+ const typeDocOutDir = path.resolve(
285
+ path.dirname(absTypeDocJsonPath),
286
+ typeDocJson.out ? typeDocJson.out : DEFAULT_REL_TYPEDOC_OUT_PATH
287
+ );
288
+
289
+ /**
290
+ * Absolute path to `mkdocs.yml`
291
+ */
292
+ const absMkdocsYmlPath = path.isAbsolute(mkDocsYmlPath)
293
+ ? mkDocsYmlPath
294
+ : path.resolve(cwd, mkDocsYmlPath);
295
+
296
+ const {docs_dir: docsDir, nav = []} = mkDocsYml;
297
+ /**
298
+ * Absolute path to the directory containing MkDocs input docs
299
+ */
300
+ const mkDocsDocsDir = path.resolve(path.dirname(absMkdocsYmlPath), docsDir ?? 'docs');
301
+
302
+ /**
303
+ * @todo
304
+ * `commands` is a dirname configurable via the `commandsDir` option added by
305
+ * `@appium/typedoc-plugin-appium`. this lives in `typedoc.json`, but in order for it to be parsed
306
+ * using TypeDoc's facilities, we have to load plugins before reading `typedoc.json`, which is
307
+ * slow. we will probably have to support this in the future, but for now, we can just hardcode it
308
+ */
309
+ const dirs = all ? await findDirsIn(typeDocOutDir) : [path.join(typeDocOutDir, 'commands')];
310
+
311
+ let shouldWriteMkDocsYml = false;
312
+
313
+ const navData = parseNav(nav);
314
+
315
+ // this is the thing which will be assigned to the `nav` prop
316
+ // and thus written to `mkdocs.yml` if there were any changes.
317
+ // we don't need the `name` prop, since the name is already present in the keypath.
318
+ const newData: Omit<ParsedNavData, 'name'>[] = [];
319
+
320
+ for await (const dir of dirs) {
321
+ const {data, changed} = await getNavItemsForDir(dir, mkDocsDocsDir, navData, nav, all);
322
+ if (changed) {
323
+ shouldWriteMkDocsYml = true;
324
+ }
325
+ newData.push(...data);
326
+ }
327
+
328
+ if (shouldWriteMkDocsYml) {
329
+ applyNavData(newData, mkDocsYml);
330
+ const yaml = stringifyYaml(mkDocsYml);
331
+ log.debug('Writing to %s:\n%s', mkDocsYmlPath, yaml);
332
+ await safeWriteFile(mkDocsYmlPath, yaml, true);
333
+ log.success(
334
+ 'Updated MkDocs navigation config for reference docs; please run "git add -A %s" and commit this change',
335
+ relMkDocsYmlPath
336
+ );
337
+ } else {
338
+ log.info('No changes needed for MkDocs config at %s', relMkDocsYmlPath);
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Options for {@linkcode updateNav}
344
+ */
345
+ export interface UpdateNavOpts {
346
+ /**
347
+ * Current working directory
348
+ */
349
+ cwd?: string;
350
+ /**
351
+ * Path to `mkdocs.yml`
352
+ */
353
+ mkdocsYml?: string;
354
+ /**
355
+ * Path to `package.json`
356
+ */
357
+ packageJson?: string;
358
+ /**
359
+ * Path to `typedoc.json`
360
+ */
361
+ typedocJson?: string;
362
+ /**
363
+ * If `true`, do not write any files
364
+ * @remarks Not yet implemented
365
+ */
366
+ dryRun?: boolean;
367
+
368
+ /**
369
+ * If `true`, add _all_ reference documentation to the navigation config (not just commands)
370
+ */
371
+ all?: boolean;
372
+ }
373
+
374
+ /**
375
+ * Used internally by {@linkcode updatedNav}
376
+ * @see {@linkcode parseNav}
377
+ */
378
+ interface ParsedNavData {
379
+ /**
380
+ * Keypath within `nav` for some file or URL
381
+ */
382
+ keypath: string;
383
+ /**
384
+ * A filepath (usually) or a URL.
385
+ * This is considered the "index" of the data, and should be unique within its parent. If it's not
386
+ * unique, then it will probably end up that way after updating...
387
+ */
388
+ fileOrUrl: string;
389
+ /**
390
+ * If this file or url has a proper name, this would be it. Most don't.
391
+ */
392
+ name?: string;
393
+ }