Skip to content

Commit

Permalink
feat: remane
Browse files Browse the repository at this point in the history
  • Loading branch information
zuofenghua committed Oct 16, 2020
1 parent 5d45532 commit 52b745a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 28 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# (WIP) doc-the-lib 📝💨
# (WIP) vlib-docsify 📝💨

[![npm](https://img.shields.io/npm/v/doc-the-lib)](https://www.npmjs.com/package/doc-the-lib)
[![npm](https://img.shields.io/npm/v/vlib-docsify)](https://www.npmjs.com/package/vlib-docsify)

> A doc generator tool for libiary. based on vitepress.
**Note this is early WIP! Currently the focus is on making doc-the-lib stable and feature complete first. It is not recommended to use this for anything serious yet.**
**Note this is early WIP! Currently the focus is on making vlib-docsify stable and feature complete first. It is not recommended to use this for anything serious yet.**

``` bash
npm install -D doc-the-lib
echo '# Hello doc-the-lib' > index.md
npm install -D vlib-docsify
echo '# Hello vlib-docsify' > index.md

# starts dev server
npx doc-the-lib
npx vlib-docsify

# build > .doc-the-lib/dist
npx doc-the-lib build
# build > .vlib-docsify/dist
npx vlib-docsify build
```
8 changes: 5 additions & 3 deletions bin/doc-the-lib.js → bin/vlib-docsify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env node
const chalk = require('chalk')
const argv = require('minimist')(process.argv.slice(2))
const portfinder = require('portfinder')

console.log(chalk.green('forked version~'))
console.log(chalk.green('[vlib-docsify] forked from vitepress~'))

console.log(chalk.cyan(`vitepress v${require('../package.json').version}`))
console.log(chalk.cyan(`vite v${require('vite/package.json').version}`))
Expand All @@ -14,10 +15,11 @@ if (root) {
}

if (!command || command === 'dev') {
const port = argv.port || 3000
require('../dist/node')
.createServer(argv)
.then((server) => {
.then(async (server) => {
portfinder.basePort = parseInt(argv.port) || 3000
const port = await portfinder.getPortPromise()
server.listen(port, () => {
console.log(`listening at http://localhost:${port}`)
})
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "doc-the-lib",
"name": "vlib-docsify",
"version": "0.2.0",
"description": "",
"main": "dist/node/index.js",
"typings": "types/index.d.ts",
"bin": {
"doc-the-lib": "bin/doc-the-lib.js"
"vlib-docsify": "bin/vlib-docsify.js"
},
"files": [
"bin",
Expand All @@ -20,12 +20,12 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/dewfall123/doc-the-lib.git"
"url": "git+https://github.com/dewfall123/vlib-docsify.git"
},
"bugs": {
"url": "https://github.com/dewfall123/doc-the-lib/issues"
"url": "https://github.com/dewfall123/vlib-docsify/issues"
},
"homepage": "https://github.com/dewfall123/doc-the-lib/#readme",
"homepage": "https://github.com/dewfall123/vlib-docsify/#readme",
"scripts": {
"dev": "run-p dev-client dev-node",
"dev-client": "tsc -w -p src/client",
Expand Down Expand Up @@ -68,6 +68,7 @@
"markdown-it-emoji": "^1.4.0",
"markdown-it-table-of-contents": "^0.4.4",
"minimist": "^1.2.5",
"portfinder": "^1.0.28",
"prismjs": "^1.20.0",
"slash": "^3.0.0",
"vite": "^1.0.0-rc.4",
Expand Down
2 changes: 1 addition & 1 deletion src/client/theme-default/components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
padding: 0.35rem 1.5rem 0.35rem 1.25rem;
line-height: 1.7;
font-size: 1.05em;
font-weight: 700;
font-weight: 500;
color: var(--text-color);
}
Expand Down
1 change: 1 addition & 0 deletions src/node/markdown/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface MarkdownParsedData {
export interface MarkdownRenderer {
__data: MarkdownParsedData
render: (src: string, env?: any) => { html: string; data: any }
root?: string
}

export const createMarkdownRenderer = (
Expand Down
4 changes: 2 additions & 2 deletions src/node/markdown/plugins/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const demoPlugin = (md: MarkdownIt) => {
const componentName = `demo${index++}`
const src = (content.match(/src=("|')(\S+)('|")/) || [])[2] ?? ''
let language = (content.match(/language=("|')(.*)('|")/) || [])[2] ?? ''
const srcPath = path.resolve((global as any).fileRoot, src)
const srcPath = path.resolve((md as any).root, src)
if (!src || !fs.existsSync(srcPath)) {
const warningMsg = `${srcPath} does not exist!`
console.warn(`[vitepress]: ${warningMsg}`)
Expand All @@ -45,7 +45,7 @@ export const demoPlugin = (md: MarkdownIt) => {
language = (src.match(/\.(.+)$/) || [])[1] ?? 'vue'
}

console.log(`srcPath=${srcPath}`)
// console.log(`srcPath=${srcPath}`)
const codeStr = fs.readFileSync(srcPath).toString()
// const { content: codeContent, data: frontmatter } = matter(codeStr)
const htmlStr = encodeURIComponent(highlight(codeStr, language))
Expand Down
4 changes: 2 additions & 2 deletions src/node/markdownToVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function createMarkdownToVueRenderFn(
injectData = true
) => {
file = path.relative(root, file)
// TODO
;(global as any).fileRoot = path.resolve(file, '../')
// record file root
md.root = path.resolve(file, '../')
const cached = cache.get(src)
if (cached) {
debug(`[cache hit] ${file}`)
Expand Down
1 change: 0 additions & 1 deletion src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ function getNextAndPrev(themeConfig: any, pagePath: string) {
export async function createServer(options: ServerConfig = {}) {
const config = await resolveConfig(options.root)

console.log(config.userConfig.viteOptions ?? {})
return createViteServer({
...(config.userConfig.viteOptions ?? {}),
...options,
Expand Down
35 changes: 29 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ astral-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==

async@^2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
dependencies:
lodash "^4.17.14"

at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
Expand Down Expand Up @@ -1145,7 +1152,7 @@ dateformat@^3.0.0:
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==

debug@^3.1.0:
debug@^3.1.0, debug@^3.1.1:
version "3.2.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
Expand Down Expand Up @@ -2346,16 +2353,16 @@ lodash.templatesettings@^4.0.0:
dependencies:
lodash._reinterpolate "^3.0.0"

lodash@^4.17.14, lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

lodash@^4.17.15:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==

lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

log-symbols@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4"
Expand Down Expand Up @@ -2602,6 +2609,13 @@ minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

mkdirp@^0.5.5:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
dependencies:
minimist "^1.2.5"

modify-values@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
Expand Down Expand Up @@ -2982,6 +2996,15 @@ please-upgrade-node@^3.2.0:
dependencies:
semver-compare "^1.0.0"

portfinder@^1.0.28:
version "1.0.28"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778"
integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==
dependencies:
async "^2.6.2"
debug "^3.1.1"
mkdirp "^0.5.5"

postcss-discard-comments@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/postcss-discard-comments/-/postcss-discard-comments-4.0.2.tgz#1fbabd2c246bff6aaad7997b2b0918f4d7af4033"
Expand Down

0 comments on commit 52b745a

Please sign in to comment.