Skip to content

Commit

Permalink
feat: Add typedoc support
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 1, 2023
1 parent ce82712 commit 512c524
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
dist
tmp
/out-tsc
docs

# dependencies
node_modules
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
"type": "module",
"scripts": {
"build": "nx run-many --target=build",
"affected": "nx affected --target=build",
"publish": "nx publish <project> [--ver=0.0.1] [--tag=latest]",
"test": "nx run-many --target=test",
"lint": "nx run-many --target=lint",
"dev:zhi-cli": "node --experimental-specifier-resolution=node --loader ts-node/esm packages/zhi-cli/index.ts",
"watch:zhi-cli": "nx run zhi-cli:build --watch",
"watch:zhi": "nx run zhi:build --watch",
"cli:zhi-cli": "node --experimental-specifier-resolution=node dist/packages/zhi-cli"
"doc": "nx doc <project>"
},
"private": true,
"devDependencies": {
Expand All @@ -37,6 +34,7 @@
"nx": "15.8.9",
"prettier": "^2.6.2",
"ts-node": "10.9.1",
"typedoc": "^0.23.28",
"typescript": "~4.9.5",
"vite": "^4.0.1",
"vite-plugin-dts": "~1.7.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/zhi-blog-api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"options": {
"lintFilePatterns": ["packages/zhi-blog-api/**/*.ts"]
}
},
"doc": {
"executor": "nx:run-commands",
"options": {
"command": "typedoc --tsconfig packages/zhi-blog-api/tsconfig.json --out docs/zhi-blog-api packages/zhi-blog-api/src/index.ts"
},
"dependsOn": ["build"]
}
},
"tags": []
Expand Down
2 changes: 1 addition & 1 deletion packages/zhi-blog-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import BlogConfig, { PageType, PasswordType } from "./lib/blogConfig"
import BlogPlaceholder from "./lib/blogPlaceholder"
import BlogApi from "./lib/zhi-blog-api"
import IBlogApi from "./lib/IBlogApi"
import type { IBlogApi } from "./lib/IBlogApi"
import Post from "./lib/models/post"
import UserBlog from "./lib/models/userBlog"
import SiteConfig from "./lib/models/siteConfig"
Expand Down
2 changes: 1 addition & 1 deletion packages/zhi-blog-api/src/lib/IBlogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ interface IBlogApi {
newMediaObject(mediaObject: MediaObject): Promise<MediaObject>
}

export default IBlogApi
export { IBlogApi }
2 changes: 1 addition & 1 deletion packages/zhi-blog-api/src/lib/blogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Post from "./models/post"
import CategoryInfo from "./models/categoryInfo"
import { version } from "../../package.json"
import MediaObject from "./models/mediaObject"
import IBlogApi from "./IBlogApi"
import type { IBlogApi } from "./IBlogApi"

/**
* 博客API
Expand Down
6 changes: 3 additions & 3 deletions packages/zhi-blog-api/src/lib/enums/postStatusEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ enum PostStatusEnum {
/**
* 已发布
*/
PostStatusEnum_Publish="publish",
PostStatusEnum_Publish = "publish",
/**
* 草稿
*/
PostStatusEnum_Draft="draft",
PostStatusEnum_Draft = "draft",
/**
* 继承
*/
PostStatusEnum_Inherit="inherit"
PostStatusEnum_Inherit = "inherit",
}

export default PostStatusEnum
8 changes: 7 additions & 1 deletion packages/zhi-blog-api/src/lib/models/mediaObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@
* @version 1.0.0
* @since 1.0.0
*/
interface MediaObject {
class MediaObject {
name: string
type: string
bits: Buffer

constructor(name: string, type: string, bits: Buffer) {
this.name = name
this.type = type
this.bits = bits
}
}

export default MediaObject
7 changes: 7 additions & 0 deletions packages/zhi-siyuan-api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"options": {
"lintFilePatterns": ["packages/zhi-siyuan-api/**/*.ts"]
}
},
"doc": {
"executor": "nx:run-commands",
"options": {
"command": "typedoc --tsconfig packages/zhi-siyuan-api/tsconfig.json --out docs/zhi-siyuan-api packages/zhi-siyuan-api/src/index.ts"
},
"dependsOn": ["build"]
}
},
"tags": []
Expand Down
2 changes: 1 addition & 1 deletion packages/zhi-siyuan-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SiyuanApi from "./lib/zhi-siyuan-api"
import { SiyuanData } from "./lib/siyuanKernelApi"
import type { SiyuanData } from "./lib/ISiyuanKernelApi"

export default SiyuanApi
export { SiyuanData }
11 changes: 9 additions & 2 deletions packages/zhi-siyuan-api/src/lib/siYuanApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import { CategoryInfo, IBlogApi, MediaObject, Post, UserBlog } from "zhi-blog-api"
import SiyuanKernelApi from "./siyuanKernelApi"
import Env from "zhi-env"
import SiyuanConfig from "./siyuanConfig"

/**
* 思源笔记API适配器
Expand All @@ -36,8 +38,13 @@ import SiyuanKernelApi from "./siyuanKernelApi"
class SiYuanApiAdaptor implements IBlogApi {
private siyuanKernelApi

constructor() {
this.siyuanKernelApi = new SiyuanKernelApi()
/**
* 初始化思源 API 适配器
*
* @param cfg - 环境变量 或者 配置项
*/
constructor(cfg: Env | SiyuanConfig) {
this.siyuanKernelApi = new SiyuanKernelApi(cfg)
}

async deletePost(postid: string): Promise<boolean> {
Expand Down
7 changes: 3 additions & 4 deletions packages/zhi-siyuan-api/src/lib/siyuanApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ class SiyuanApi {
/**
* 构造思源 API对象
*
* @param env - 可选,注意:serverApi必须传递env才能使用
* @param cfg - 可选,注意:y优先级比环境变量高
* @param cfg - 环境变量 或者 配置项
*/
constructor(env?: Env, cfg?: SiyuanConfig) {
this.kernelApi = new SiyuanKernelApi(env, cfg)
constructor(cfg: Env | SiyuanConfig) {
this.kernelApi = new SiyuanKernelApi(cfg)
this.clientApi = new SiyuanClientApi()
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zhi-siyuan-api/src/lib/siyuanKernelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import LogFactory, { DefaultLogger, EnvHelper, LogLevelEnum } from "zhi-log"
import { name, version } from "../../package.json"
import ZhiCommon from "zhi-common"
import SiyuanConstants from "./siyuanConstants"
import ISiyuanKernelApi, { SiyuanData } from "./ISiyuanKernelApi"
import ISiyuanKernelApi, { type SiyuanData } from "./ISiyuanKernelApi"

/**
* 思源笔记服务端API v2.8.2
Expand Down
6 changes: 2 additions & 4 deletions packages/zhi-siyuan-api/src/lib/siyuanPlaceholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
* questions.
*/

import { BlogPlaceholder } from "zhi-blog-api";
import { BlogPlaceholder } from "zhi-blog-api"

/**
* 思源笔记操作提示
*/
class SiyuanPlaceholder extends BlogPlaceholder{

}
class SiyuanPlaceholder extends BlogPlaceholder {}

export default SiyuanPlaceholder
61 changes: 58 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 512c524

Please sign in to comment.