Compodoc 的常用命令

101 阅读2分钟

最近在学习 nestjs,用到了 Compodoc。发现配置文件里面的可配置项挺多的,记录一下自己用到的配置项

官网:compodoc.app/guides/inst…

首先安装 compodoc。 然后在 package.json 里面写一条 script 启动 compodoc。

image.png

新建一个compodoc配置文件,文件名可以随便取,要和package.json 里面的命令路径对的上。

compodoc配置文件要写上一个 $schema .这样写 json 的时候才有语法提示。

{   
    "$schema": "./node_modules/@compodoc/compodoc/src/config/schema.json",
    "port": 8888,
    "theme": "gitbook",
    "language": "zh-CN",
    "open": true,
    "serve": true,
    "watch": true,
    "tsconfig": "./tsconfig.json"
}

port

运行的端口号, 搭配serve使用

serve

创建一个服务器打开编译后的文件

watch

监听文件改动,重新生成文件

open

编译文件后自动访问文档地址

language

设置语言,我设置后没有效果

贴一下完整配置项

{
    "$id": "http://compodoc.app/schema",
    "type": "object",
    "definitions": {},
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "config": {
            "$id": "/properties/config",
            "type": "string",
            "title": "A configuration file : .compodocrc, .compodocrc.json, .compodocrc.yaml or compodoc property in package.json",
            "default": "",
            "examples": [".compodocrc"]
        },
        "tsconfig": {
            "$id": "/properties/tsconfig",
            "type": "string",
            "title": "A tsconfig.json file",
            "default": "",
            "examples": [""]
        },
        "output": {
            "$id": "/properties/output",
            "type": "string",
            "title": "Where to store the generated documentation",
            "default": "documentation",
            "examples": [""]
        },
        "extTheme": {
            "$id": "/properties/extTheme",
            "type": "string",
            "title": "External styling theme file",
            "default": "",
            "examples": [""]
        },
        "name": {
            "$id": "/properties/name",
            "type": "string",
            "title": "Title documentation",
            "default": "Application documentation",
            "examples": [""]
        },
        "language": {
            "$id": "/properties/language",
            "type": "string",
            "title": "Language used for the generated documentation (en-US, fr-FR, zh-CN)",
            "default": "en-US",
            "examples": [""]
        },
        "assetsFolder": {
            "$id": "/properties/assetsFolder",
            "type": "string",
            "title": "External assets folder to copy in generated documentation folder",
            "default": "",
            "examples": [""]
        },
        "open": {
            "$id": "/properties/open",
            "type": "boolean",
            "title": "Open the generated documentation",
            "default": false,
            "examples": [false]
        },
        "silent": {
            "$id": "/properties/silent",
            "type": "boolean",
            "title": "In silent mode, log messages aren't logged in the console",
            "default": false,
            "examples": [false]
        },
        "serve": {
            "$id": "/properties/serve",
            "type": "boolean",
            "title": "Serve generated documentation (default http://localhost:8080/)",
            "default": false,
            "examples": [true]
        },
        "port": {
            "$id": "/properties/port",
            "type": "integer",
            "title": "Change default serving port",
            "default": 0,
            "examples": [8080]
        },
        "watch": {
            "$id": "/properties/watch",
            "type": "boolean",
            "title": "Watch source files after serve and force documentation rebuild",
            "default": false,
            "examples": [false]
        },
        "exportFormat": {
            "$id": "/properties/exportFormat",
            "type": "string",
            "title": "Export in specified format (json, html)",
            "default": "",
            "examples": ["html"]
        },
        "files": {
            "$id": "/properties/files",
            "type": "string",
            "title": "Files provided by external tool, used for coverage test",
            "default": "",
            "examples": ["src/myapp.component.ts"]
        },
        "theme": {
            "$id": "/properties/theme",
            "type": "string",
            "title": "Choose one of available themes, default is 'gitbook' (laravel, original, material, postmark, readthedocs, stripe, vagrant)",
            "default": "gitbook",
            "examples": [""]
        },
        "hideGenerator": {
            "$id": "/properties/hideGenerator",
            "type": "boolean",
            "title": "Do not print the Compodoc link at the bottom of the page",
            "default": false,
            "examples": [false]
        },
        "hideDarkModeToggle": {
            "$id": "/properties/hideDarkModeToggle",
            "type": "boolean",
            "title": "Do not show dark mode toggle button at the top right position of the page",
            "default": false,
            "examples": [false]
        },
        "toggleMenuItems": {
            "$id": "/properties/toggleMenuItems",
            "type": "array",
            "items": {
                "$id": "/properties/toggleMenuItems/items",
                "type": "string",
                "title": "Close by default items in the menu values : ['all'] or one of these ['modules','components','directives','classes','injectables','interfaces','pipes','additionalPages']",
                "default": "",
                "examples": ["all"]
            }
        },
        "navTabConfig": {
            "$id": "/properties/navTabConfig",
            "type": "array",
            "items": {
                "$id": "/properties/navTabConfig/items",
                "type": "object",
                "properties": {
                    "id": {
                        "$id": "/properties/navTabConfig/items/properties/id",
                        "type": "string",
                        "title": "The Id Schema ",
                        "default": "",
                        "examples": [""]
                    },
                    "label": {
                        "$id": "/properties/navTabConfig/items/properties/label",
                        "type": "string",
                        "title": "The Label Schema ",
                        "default": "",
                        "examples": [""]
                    }
                }
            }
        },
        "templates": {
            "$id": "/properties/templates",
            "type": "string",
            "title": "Path to directory of Handlebars templates to override built-in templates",
            "default": "",
            "examples": [""]
        },
        "includes": {
            "$id": "/properties/includes",
            "type": "string",
            "title": "Path of external markdown files to include",
            "default": "",
            "examples": [""]
        },
        "includesName": {
            "$id": "/properties/includesName",
            "type": "string",
            "title": "Name of item menu of externals markdown files",
            "default": "",
            "examples": [""]
        },
        "coverageTest": {
            "$id": "/properties/coverageTest",
            "type": "integer",
            "title": "Test command of documentation coverage with a threshold (default 70)",
            "default": 70,
            "examples": [70]
        },
        "coverageMinimumPerFile": {
            "$id": "/properties/coverageMinimumPerFile",
            "type": "integer",
            "title": "Test command of documentation coverage per file with a minimum (default 0)",
            "default": 0,
            "examples": [0]
        },
        "coverageTestThresholdFail": {
            "$id": "/properties/coverageTestThresholdFail",
            "type": "boolean",
            "title": "Test command of documentation coverage (global or per file) will fail with error or just warn user (true: error, false: warn)",
            "default": false,
            "examples": [true]
        },
        "disableSourceCode": {
            "$id": "/properties/disableSourceCode",
            "type": "boolean",
            "title": "Do not add source code tab and links to source code",
            "default": false,
            "examples": [false]
        },
        "disableDomTree": {
            "$id": "/properties/disableDomTree",
            "type": "boolean",
            "title": "Do not add dom tree tab",
            "default": false,
            "examples": [false]
        },
        "disableTemplateTab": {
            "$id": "/properties/disableTemplateTab",
            "type": "boolean",
            "title": "Do not add template tab",
            "default": false,
            "examples": [false]
        },
        "disableGraph": {
            "$id": "/properties/disableGraph",
            "type": "boolean",
            "title": "Do not add the dependency graph",
            "default": false,
            "examples": [false]
        },
        "disableCoverage": {
            "$id": "/properties/disableCoverage",
            "type": "boolean",
            "title": "Do not add the documentation coverage report",
            "default": false,
            "examples": [false]
        },
        "disablePrivate": {
            "$id": "/properties/disablePrivate",
            "type": "boolean",
            "title": "Do not show private in generated documentation",
            "default": false,
            "examples": [false]
        },
        "disableProtected": {
            "$id": "/properties/disableProtected",
            "type": "boolean",
            "title": "Do not show protected in generated documentation",
            "default": false,
            "examples": [false]
        },
        "disableInternal": {
            "$id": "/properties/disableInternal",
            "type": "boolean",
            "title": "Do not show @internal in generated documentation",
            "default": false,
            "examples": [false]
        },
        "disableLifeCycleHooks": {
            "$id": "/properties/disableLifeCycleHooks",
            "type": "boolean",
            "title": "Do not show Angular lifecycle hooks in generated documentation",
            "default": false,
            "examples": [false]
        },
        "disableConstructors": {
            "$id": "/properties/disableConstructors",
            "type": "boolean",
            "title": "Do not show constructors in generated documentation",
            "default": false,
            "examples": [false]
        },
        "disableRoutesGraph": {
            "$id": "/properties/disableRoutesGraph",
            "type": "boolean",
            "title": "Do not add the routes graph",
            "default": false,
            "examples": [false]
        },
        "disableSearch": {
            "$id": "/properties/disableSearch",
            "type": "boolean",
            "title": "Do not add the search input",
            "default": false,
            "examples": [false]
        },
        "disableDependencies": {
            "$id": "/properties/disableDependencies",
            "type": "boolean",
            "title": "Do not add the dependencies list",
            "default": false,
            "examples": [false]
        },
        "disableProperties": {
            "$id": "/properties/disableProperties",
            "type": "boolean",
            "title": "Do not add the properties list",
            "default": false,
            "examples": [false]
        },
        "minimal": {
            "$id": "/properties/minimal",
            "type": "boolean",
            "title": "Minimal mode with only documentation. No search, no graph, no coverage.",
            "default": false,
            "examples": [false]
        },
        "customFavicon": {
            "$id": "/properties/customFavicon",
            "type": "string",
            "title": "Use a custom favicon",
            "default": "",
            "examples": [""]
        },
        "customLogo": {
            "$id": "/properties/customLogo",
            "type": "string",
            "title": "Use a custom logo",
            "default": "",
            "examples": [""]
        },
        "gaID": {
            "$id": "/properties/gaID",
            "type": "string",
            "title": "Google Analytics tracking ID",
            "default": "",
            "examples": [""]
        },
        "gaSite": {
            "$id": "/properties/gaSite",
            "type": "string",
            "title": "Google Analytics site name",
            "default": "",
            "examples": [""]
        }
    }
}