@appium/docutils 0.4.12 → 1.0.1

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 (75) hide show
  1. package/base-mkdocs.yml +45 -5
  2. package/build/lib/builder/deploy.d.ts +4 -4
  3. package/build/lib/builder/deploy.d.ts.map +1 -1
  4. package/build/lib/builder/deploy.js +5 -4
  5. package/build/lib/builder/deploy.js.map +1 -1
  6. package/build/lib/builder/index.d.ts +0 -2
  7. package/build/lib/builder/index.d.ts.map +1 -1
  8. package/build/lib/builder/index.js +0 -2
  9. package/build/lib/builder/index.js.map +1 -1
  10. package/build/lib/builder/site.d.ts +2 -2
  11. package/build/lib/builder/site.js +2 -2
  12. package/build/lib/cli/command/build.d.ts +8 -45
  13. package/build/lib/cli/command/build.d.ts.map +1 -1
  14. package/build/lib/cli/command/build.js +11 -56
  15. package/build/lib/cli/command/build.js.map +1 -1
  16. package/build/lib/cli/command/init.d.ts +0 -27
  17. package/build/lib/cli/command/init.d.ts.map +1 -1
  18. package/build/lib/cli/command/init.js +0 -27
  19. package/build/lib/cli/command/init.js.map +1 -1
  20. package/build/lib/cli/command/validate.d.ts +0 -24
  21. package/build/lib/cli/command/validate.d.ts.map +1 -1
  22. package/build/lib/cli/command/validate.js +2 -26
  23. package/build/lib/cli/command/validate.js.map +1 -1
  24. package/build/lib/constants.d.ts +3 -14
  25. package/build/lib/constants.d.ts.map +1 -1
  26. package/build/lib/constants.js +4 -15
  27. package/build/lib/constants.js.map +1 -1
  28. package/build/lib/fs.d.ts +0 -29
  29. package/build/lib/fs.d.ts.map +1 -1
  30. package/build/lib/fs.js +4 -57
  31. package/build/lib/fs.js.map +1 -1
  32. package/build/lib/index.d.ts +0 -1
  33. package/build/lib/index.d.ts.map +1 -1
  34. package/build/lib/index.js +0 -1
  35. package/build/lib/index.js.map +1 -1
  36. package/build/lib/init.d.ts +7 -131
  37. package/build/lib/init.d.ts.map +1 -1
  38. package/build/lib/init.js +2 -55
  39. package/build/lib/init.js.map +1 -1
  40. package/build/lib/model.d.ts +0 -11
  41. package/build/lib/model.d.ts.map +1 -1
  42. package/build/lib/validate.d.ts +2 -30
  43. package/build/lib/validate.d.ts.map +1 -1
  44. package/build/lib/validate.js +2 -93
  45. package/build/lib/validate.js.map +1 -1
  46. package/lib/builder/deploy.ts +17 -15
  47. package/lib/builder/index.ts +0 -2
  48. package/lib/builder/site.ts +6 -6
  49. package/lib/cli/command/build.ts +12 -59
  50. package/lib/cli/command/init.ts +0 -27
  51. package/lib/cli/command/validate.ts +3 -27
  52. package/lib/constants.ts +4 -17
  53. package/lib/fs.ts +16 -84
  54. package/lib/index.ts +0 -1
  55. package/lib/init.ts +9 -106
  56. package/lib/model.ts +0 -14
  57. package/lib/validate.ts +23 -172
  58. package/package.json +7 -13
  59. package/requirements.txt +4 -3
  60. package/tsconfig.json +1 -0
  61. package/build/lib/builder/nav.d.ts +0 -81
  62. package/build/lib/builder/nav.d.ts.map +0 -1
  63. package/build/lib/builder/nav.js +0 -288
  64. package/build/lib/builder/nav.js.map +0 -1
  65. package/build/lib/builder/reference.d.ts +0 -57
  66. package/build/lib/builder/reference.d.ts.map +0 -1
  67. package/build/lib/builder/reference.js +0 -111
  68. package/build/lib/builder/reference.js.map +0 -1
  69. package/build/lib/mike.d.ts +0 -81
  70. package/build/lib/mike.d.ts.map +0 -1
  71. package/build/lib/mike.js +0 -146
  72. package/build/lib/mike.js.map +0 -1
  73. package/lib/builder/nav.ts +0 -402
  74. package/lib/builder/reference.ts +0 -171
  75. package/lib/mike.js +0 -153
@@ -1,171 +0,0 @@
1
- /**
2
- * Builds reference documentation via TypeDoc. The output is _markdown_, intended to be imported into MkDocs.
3
- *
4
- * @module
5
- */
6
-
7
- import {fs} from '@appium/support';
8
- import _ from 'lodash';
9
- import path from 'node:path';
10
- import {Application, ArgumentsReader, TypeDocOptions, TypeDocReader} from 'typedoc';
11
- import {
12
- DEFAULT_LOG_LEVEL,
13
- DEFAULT_REL_TYPEDOC_OUT_PATH,
14
- NAME_BIN,
15
- NAME_TYPEDOC_JSON,
16
- } from '../constants';
17
- import {DocutilsError} from '../error';
18
- import {findTypeDocJsonPath, readTypedocJson} from '../fs';
19
- import {getLogger} from '../logger';
20
- import {argify, relative, stopwatch} from '../util';
21
-
22
- const log = getLogger('builder:reference');
23
-
24
- /**
25
- * Executes TypeDoc _in the current process_
26
- *
27
- * You will probably want to run `updateNav()` after this.
28
- *
29
- * @privateRemarks Monkeypatches TypeDoc's homebrew "glob" implementation because it is broken
30
- * @parma typeDocJsonPath - Path to `typedoc.json`
31
- * @param opts - TypeDoc options
32
- */
33
- export async function runTypedoc(typeDocJsonPath: string, opts: Record<string, string>) {
34
- const args = argify(opts);
35
- log.debug('TypeDoc args:', args);
36
- const app = new Application();
37
- app.options.setValue('plugin', [
38
- 'typedoc-plugin-markdown',
39
- 'typedoc-plugin-resolve-crossmodule-references',
40
- '@appium/typedoc-plugin-appium',
41
- ]);
42
- app.options.addReader(new TypeDocReader());
43
- app.options.addReader(new ArgumentsReader(100, args));
44
- app.bootstrap({options: path.dirname(typeDocJsonPath)});
45
- const out = app.options.getValue('out');
46
- const project = app.convert();
47
- if (project) {
48
- return await app.generateDocs(project, out);
49
- }
50
-
51
- throw new DocutilsError('TypeDoc found nothing to document. Is your package empty?');
52
- }
53
-
54
- /**
55
- * Options for {@linkcode buildReferenceDocs}
56
- */
57
- export interface BuildReferenceOptions {
58
- /**
59
- * Path to `typedoc.json`
60
- */
61
- typedocJson?: string;
62
- /**
63
- * Current working directory
64
- */
65
- cwd?: string;
66
- /**
67
- * Path to `package.json`
68
- */
69
- packageJson?: string;
70
- /**
71
- * Path to `tsconfig.json`
72
- */
73
- tsconfigJson?: string;
74
- /**
75
- * "Title" for generated docs; this corresponds to {@linkcode typedoc.TypeDocOptionMap.name}
76
- */
77
- title?: string;
78
- /**
79
- * This is here because we pass it thru to TypeDoc
80
- */
81
- logLevel?: LogLevelName;
82
- }
83
-
84
- /**
85
- * Log level names as supported by this package
86
- *
87
- * Used to convert our log level to TypeDoc's
88
- */
89
- type LogLevelName = 'debug' | 'info' | 'error' | 'warn';
90
-
91
- /**
92
- * Mapping of whatever our log level is to whatever TypeDoc's should be.
93
- *
94
- * TypeDoc's "info" is too verbose for our needs, and it's our default, so
95
- * we map it to "warn".
96
- */
97
- const TypeDocLogLevelMap: Record<LogLevelName, string> = {
98
- debug: 'Verbose',
99
- info: 'Warn',
100
- warn: 'Warn',
101
- error: 'Error',
102
- };
103
-
104
- /**
105
- * Build reference documentation via TypeDoc
106
- * @param opts - Options
107
- */
108
- export async function buildReferenceDocs({
109
- typedocJson: typeDocJsonPath,
110
- cwd = process.cwd(),
111
- tsconfigJson: tsconfig,
112
- logLevel = DEFAULT_LOG_LEVEL,
113
- title,
114
- }: BuildReferenceOptions = {}) {
115
- const stop = stopwatch('buildReferenceDocs');
116
- typeDocJsonPath = typeDocJsonPath
117
- ? path.resolve(cwd, typeDocJsonPath)
118
- : await findTypeDocJsonPath(cwd);
119
- if (!typeDocJsonPath) {
120
- throw new DocutilsError(
121
- `Could not find ${NAME_TYPEDOC_JSON} from ${cwd}; run "${NAME_BIN}" to create it`
122
- );
123
- }
124
- const pkgRoot = fs.findRoot(cwd);
125
- const relativePath = relative(cwd);
126
- const relativeTypeDocJsonPath = relativePath(typeDocJsonPath);
127
- log.debug(`Using ${relativeTypeDocJsonPath} as typedoc.json`);
128
-
129
- let typeDocJson: Readonly<Partial<TypeDocOptions>>;
130
- // we only need typedoc.json to make sure we have a custom "out" path.
131
- try {
132
- typeDocJson = readTypedocJson(typeDocJsonPath);
133
- log.debug('Contents of %s: %O', relativeTypeDocJsonPath, typeDocJson);
134
- } catch (err) {
135
- log.error(err);
136
- throw new DocutilsError(
137
- `Could not read ${relativeTypeDocJsonPath}; run "${NAME_BIN} init" to create it`
138
- );
139
- }
140
-
141
- // if for some reason "out" is not in typedoc.json, we want to use our default path.
142
- // otherwise, typedoc's default behavior is to write to the "docs" dir, which is the same dir that
143
- // we use (by default) as a source dir for the mkdocs site--which might contain files under vcs.
144
- let out: string | undefined;
145
- if (typeDocJson.out) {
146
- log.debug(`Found "out" option in ${NAME_TYPEDOC_JSON}: ${typeDocJson.out}`);
147
- } else {
148
- out = path.relative(
149
- path.dirname(typeDocJsonPath),
150
- path.join(pkgRoot, DEFAULT_REL_TYPEDOC_OUT_PATH)
151
- );
152
- log.debug('Setting "out" option to %s', out);
153
- }
154
-
155
- const extraTypedocOpts = _.pickBy(
156
- {tsconfig, name: title, out, logLevel: TypeDocLogLevelMap[logLevel]},
157
- Boolean
158
- ) as Record<string, string>;
159
-
160
- try {
161
- await runTypedoc(typeDocJsonPath, extraTypedocOpts);
162
- const finalOut = (typeDocJson.out ?? out) as string;
163
- log.success(
164
- 'Reference docs built at %s (%dms)',
165
- path.isAbsolute(finalOut) ? relativePath(finalOut) : finalOut,
166
- stop()
167
- );
168
- } catch (err) {
169
- log.error(err);
170
- }
171
- }
package/lib/mike.js DELETED
@@ -1,153 +0,0 @@
1
- /**
2
- * API around `mike`, a tool for deploying multiple versions of MkDocs-built sites to GitHub Pages
3
- * @module
4
- */
5
-
6
- import {exec} from 'teen_process';
7
- // eslint-disable-next-line import/no-unresolved
8
- import log from './logger';
9
-
10
- const DEFAULT_REMOTE = 'origin';
11
- const DEFAULT_BRANCH = 'gh-pages';
12
- const MIKE_VER_STRING = 'mike 1.';
13
-
14
- /**
15
- * @deprecated Use the `deploy` export from `@appium/docutils`
16
- */
17
- export class Mike {
18
- /** @type {string} */ remote;
19
- /** @type {string} */ branch;
20
- /** @type {string?} */ prefix;
21
- /** @type {string} */ configFile;
22
- /** @type {boolean} */ _mikeVerified = false;
23
-
24
- constructor(/** @type MikeOpts */ opts) {
25
- this.remote = opts.remote || DEFAULT_REMOTE;
26
- this.branch = opts.branch || DEFAULT_BRANCH;
27
- this.prefix = opts.prefix;
28
- this.configFile = opts.configFile;
29
- }
30
-
31
- /**
32
- * Throw an error if the 'mike' binary cannot be found
33
- *
34
- * @throws {Error}
35
- */
36
- async verifyMike() {
37
- if (this._mikeVerified) {
38
- return;
39
- }
40
- try {
41
- const {stdout} = await this.exec('--version', [], false);
42
- if (!stdout.includes(MIKE_VER_STRING)) {
43
- throw new Error('Mike was installed but was not version 1.x');
44
- }
45
- } catch (err) {
46
- throw new Error(`Could not verify appropriate mike binary exists: ${err}`);
47
- }
48
- this._mikeVerified = true;
49
- }
50
-
51
- /**
52
- * Get an array of args based on the class members that can be used with Mike-related subprocess
53
- * execution
54
- *
55
- * @param {string} cmdName - the name of the mike command to run
56
- * @param {string[]} cmdArgs - an array of command-specific arguments
57
- *
58
- * @returns {string[]}
59
- */
60
- getMikeArgs(cmdName, cmdArgs) {
61
- return [
62
- cmdName,
63
- ...cmdArgs,
64
- '--config-file',
65
- this.configFile,
66
- '--remote',
67
- this.remote,
68
- '--branch',
69
- this.branch,
70
- '--prefix',
71
- this.prefix,
72
- ];
73
- }
74
-
75
- /**
76
- * Exec mike as a subprocess
77
- *
78
- * @param {string} mikeCmd - the mike command to run
79
- * @param {string[]} [mikeArgs=[]] - the arguments to pass to the mike command
80
- * @param {boolean?} [verify=true] - whether to verify mike exists first
81
- *
82
- * @returns {Promise<import('teen_process').ExecResult<string>>}
83
- */
84
- async exec(mikeCmd, mikeArgs = [], verify = true) {
85
- if (verify) {
86
- await this.verifyMike();
87
- }
88
- const args = this.getMikeArgs(mikeCmd, mikeArgs);
89
- log.debug(`Running mike ${args.join(' ')}`);
90
- return await exec('mike', args);
91
- }
92
-
93
- /**
94
- * Return the list of mike deploys
95
- *
96
- * @returns {string[]}
97
- */
98
- async list() {
99
- const {stdout} = await this.exec('list');
100
- return stdout
101
- .split('\n')
102
- .map((s) => s.trim())
103
- .filter(Boolean);
104
- }
105
-
106
- /**
107
- * Set the default version or alias
108
- *
109
- * @param {string} alias - the version or alias
110
- */
111
- async setDefault(alias) {
112
- await this.exec('set-default', [alias]);
113
- }
114
-
115
- /**
116
- * Deploy docs to the branch
117
- *
118
- * @param {MikeDeployOpts} opts - the deploy options
119
- */
120
- async deploy(opts) {
121
- const args = [opts.version];
122
- if (opts.alias) {
123
- args.push(opts.alias, '--update-aliases');
124
- }
125
- if (opts.shouldPush) {
126
- args.push('--push');
127
- }
128
- if (opts.shouldRebase) {
129
- args.push('--rebase');
130
- }
131
- if (opts.commit) {
132
- args.push('--message', opts.commit);
133
- }
134
- await this.exec('deploy', args);
135
- }
136
- }
137
-
138
- /**
139
- * @typedef MikeOpts - options for instantiating a Mike object
140
- * @property {string} [remote="origin"] - the git remote to push docs to
141
- * @property {string} [branch="gh-pages"] - the git branch to push docs to
142
- * @property {string?} prefix - the path prefix on the branch if any
143
- * @property {string} configFile - the mkdocs config file to use
144
- */
145
-
146
- /**
147
- * @typedef MikeDeployOpts - options for deploying docs with Mike
148
- * @param {string} version - the version to deploy
149
- * @param {string?} alias - the alias to alias (or re-alias) the version
150
- * @param {string?} commit - the commit message to use as an override
151
- * @param {boolean?} shouldPush - whether mike should push the commits to the remote
152
- * @param {boolean?} shouldRebase - whether mike should rebase
153
- */