-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7404787
commit b228007
Showing
21 changed files
with
116 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
import { Command } from '@commander-js/extra-typings'; | ||
import path from 'path'; | ||
import { DOCS_DIR } from '@internals/common/constants'; | ||
import { DOCS_DIR, EXAMPLES_DIR } from '@internals/common/constants'; | ||
import { mkdirp } from '@internals/common/fs'; | ||
import { clearOutMarkdownFiles } from '../../../lib/utils/clear-out-markdown-files.js'; | ||
import { writeGuideDocs } from '../../../lib/commands/write/docs/guides.js'; | ||
import { Opts } from './index.js'; | ||
import { info, verbose } from '@internals/common/logger'; | ||
import { startWatch } from '../../../lib/cli/start-watch.js'; | ||
|
||
const EXAMPLES_DOCS_DEST = path.resolve(DOCS_DIR, 'docs/documentation/guides'); | ||
|
||
const writeGuideDocumentation = async ({ shouldClearMarkdown }: Pick<Opts, 'shouldClearMarkdown'>) => { | ||
info('Writing guides documentation'); | ||
await mkdirp(EXAMPLES_DOCS_DEST); | ||
if (shouldClearMarkdown) { | ||
verbose(`Clearing out markdown files in ${EXAMPLES_DOCS_DEST}`) | ||
await clearOutMarkdownFiles(EXAMPLES_DOCS_DEST); | ||
} | ||
|
||
return writeGuideDocs(EXAMPLES_DOCS_DEST); | ||
}; | ||
|
||
export default (program: Command) => program.command('guides') | ||
.description('Write Guides documentation') | ||
.action(async (opts) => { | ||
await mkdirp(EXAMPLES_DOCS_DEST); | ||
if ('shouldClearMarkdown' in opts && opts.shouldClearMarkdown) { | ||
await clearOutMarkdownFiles(EXAMPLES_DOCS_DEST); | ||
.action(async ({ watch, shouldClearMarkdown }: Opts) => { | ||
if (watch) { | ||
return startWatch( | ||
`pnpm cli write docs model ${shouldClearMarkdown ? '-c' : ''}`, | ||
[ | ||
path.join(EXAMPLES_DIR, '**/*.md'), | ||
], { | ||
persistent: true, | ||
}); | ||
} | ||
|
||
return await writeGuideDocs(EXAMPLES_DOCS_DEST); | ||
return writeGuideDocumentation({ shouldClearMarkdown }) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
import { Command } from '@commander-js/extra-typings'; | ||
import path from 'path'; | ||
import { DOCS_DIR } from '@internals/common/constants'; | ||
import { CORE_DIR, DOCS_DIR, MODELS_DIR, UPSCALER_DIR } from '@internals/common/constants'; | ||
import { mkdirp } from '@internals/common/fs'; | ||
import { clearOutMarkdownFiles } from '../../../lib/utils/clear-out-markdown-files.js'; | ||
import { writeModelReadmes } from '../../../lib/commands/write/docs/models.js'; | ||
import chokidar from 'chokidar'; | ||
import { startWatch } from '../../../lib/cli/start-watch.js'; | ||
import { Opts } from './index.js'; | ||
import { verbose } from '@internals/common/logger'; | ||
import { info } from 'console'; | ||
|
||
const targetDocDir = path.resolve(DOCS_DIR, 'docs/models/available'); | ||
|
||
const writeModelsDocumentation = async ({ shouldClearMarkdown }: Pick<Opts, 'shouldClearMarkdown'>) => { | ||
info('Writing models documentation'); | ||
await mkdirp(targetDocDir); | ||
if (shouldClearMarkdown) { | ||
verbose(`Clearing out markdown files in ${targetDocDir}`) | ||
await clearOutMarkdownFiles(targetDocDir); | ||
} | ||
|
||
return writeModelReadmes(targetDocDir); | ||
}; | ||
|
||
export default (program: Command) => program.command('models') | ||
.description('Write Model readme documentation') | ||
.action(async (opts) => { | ||
await mkdirp(targetDocDir); | ||
if ('shouldClearMarkdown' in opts && opts.shouldClearMarkdown) { | ||
await clearOutMarkdownFiles(targetDocDir); | ||
} | ||
|
||
if ('watch' in opts && opts.watch) { | ||
const watcher = chokidar.watch([ | ||
'../packages/core/**/*', | ||
'../packages/upscalerjs/**/*', | ||
'../internals/cli/src/lib/write/docs/api/**/*', | ||
], { | ||
ignored: '../packages/upscalerjs/**/*.generated.ts', | ||
.action(({ watch, shouldClearMarkdown }: Opts) => { | ||
if (watch) { | ||
return startWatch( | ||
`pnpm cli write docs model ${shouldClearMarkdown ? '-c' : ''}`, | ||
[ | ||
path.join(MODELS_DIR, '**/*.md'), | ||
], { | ||
persistent: true, | ||
}); | ||
watcher.on('all', () => writeModelReadmes(targetDocDir)); | ||
} else { | ||
return await writeModelReadmes(targetDocDir); | ||
} | ||
return writeModelsDocumentation({ shouldClearMarkdown }); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.