Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Dec 22, 2022
1 parent 973c289 commit 7275477
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"tools:bump": "ts-node tools/*/bump-version && yarn changelog",
"tools:bump-nightly": "ts-node tools/src/bump-version --nightly",
"tools:deploy": "ts-node tools/src/deploy",
"tools:docs-api": "ts-node --esm --project ./tools/tsconfig.tn.json tools/src/generate-api-docs.ts",
"watch-docs": "ts-node --esm --project ./tools/tsconfig.tn.json ./tools/src/markdown-to-html/markdown-to-html",
"tools:docs-api": "ts-node --esm --project ./tools/tsconfig.tn.json ./tools/src/generate-api-docs.mts",
"watch-docs": "ts-node --esm --project ./tools/tsconfig.tn.json ./tools/src/markdown-to-html/markdown-to-html.mts",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"serve:lib": "hs dist/docs-content -p 1212 -g --cors 'Access-Control-Allow-Origin' -c0",
"build:schematics": "tsc -p src/lib/schematics/tsconfig.json && cp -r src/lib/schematics/ dist/@alyle/ui/ && rm -rf dist/@alyle/ui/schematics/**/*.ts",
Expand Down
25 changes: 13 additions & 12 deletions tools/src/generate-api-docs.ts → tools/src/generate-api-docs.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as ts from 'typescript';
import ts from 'typescript';
import * as path from 'path';
import * as fs from 'fs';
import chalk from 'chalk';
import { Application, TypeDocReader, TSConfigReader, ProjectReflection, DeclarationReflection, Reflection } from 'typedoc';

import { highlight } from './html-loader/highlight';
import { hashCode } from './utils/hash-code';
import { highlight } from './html-loader/highlight.mjs';
import { hashCode } from './utils/hash-code.mjs';
const { readFile, mkdir, writeFile } = fs.promises;

interface PkgSymbol {
Expand Down Expand Up @@ -56,9 +56,9 @@ async function render() {
if (!child.children) {
continue;
}
let pkgName = child.sources![0].fileName.replace(/src\/lib/, '@alyle/ui');
let pkgName = child.sources![0]!.fileName.replace(/src\/lib/, '@alyle/ui');
pkgName = path.dirname(pkgName);
console.log(child.sources![0].fileName);
console.log(child.sources![0]!.fileName);
pkgName = pkgName.endsWith('/') ? pkgName.slice(0, -1) : pkgName;
console.log(chalk.greenBright(`\nPackage: ${pkgName}`));
let API = APIList.find(api => api.pkg === pkgName);
Expand All @@ -74,19 +74,19 @@ async function render() {
APIList.push(API);
}
for (const _child of child.children) {
const file = _child.sources![0].fileName;
const file = _child.sources![0]!.fileName;
const { name, decorators, kindString } = _child;
const type = decorators
? decorators[0].name
? decorators[0]!.name
: (kindString! === 'Variable' ? 'Const' : kindString!);
const symbol = hasTag(_child, 'decorator')
? 'Decorator'
: decorators
? decorators[0].name
? decorators[0]!.name
: _child.flags.isConst
? 'Const'
: (kindString! === 'Variable' ? 'Const' : kindString!);
const Type = `${toCamelcase(type)}List`;
// const Type = `${toCamelcase(type)}List`;
if (
!checkIfContainTagPrivate(_child) && !hasTag(_child, 'docsPrivate') && !name.startsWith('_')
) {
Expand Down Expand Up @@ -206,6 +206,7 @@ async function render() {
await generateJson();
await render();
})().catch((error) => {
console.log(error);
throw new Error(error);
});

Expand All @@ -217,7 +218,7 @@ function groupBy<T>(xs: T[], key: string): { key: string, items: T[]}[] {
items: []
}) as true /** <-- This always returns true, since an item is never removed */)
&& rv[rv.length - 1]);
item.items.push(x);
item!.items.push(x);
return rv;
}, [] as { key: string, items: T[]}[]);
}
Expand Down Expand Up @@ -256,7 +257,7 @@ function toCamelcase(str: string) {

function hasTag(refl: DeclarationReflection, tag: string): boolean {
const comment: Reflection['comment'] = refl.comment
|| (refl['signatures'] && refl['signatures'].length ? refl['signatures'][0].comment : undefined);
|| (refl['signatures'] && refl['signatures'].length ? refl['signatures'][0]!.comment : undefined);
if (comment && comment.tags) {
return comment.tags.some((_: any) => _.tag === tag);
} else {
Expand All @@ -266,7 +267,7 @@ function hasTag(refl: DeclarationReflection, tag: string): boolean {

function checkIfContainTagPrivate(refl: DeclarationReflection): boolean {
const comment: Reflection['comment'] = refl.comment
|| (refl['signatures'] && refl['signatures'].length ? refl['signatures'][0].comment : undefined);
|| (refl['signatures'] && refl['signatures'].length ? refl['signatures'][0]!.comment : undefined);
if (comment && comment.tags) {
return comment.tags.some((_: any) => _.tag === 'docs-private');
} else {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 7275477

Please sign in to comment.