-
-
Notifications
You must be signed in to change notification settings - Fork 285
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
Showing
38 changed files
with
337 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```ts | ||
<%- code %> | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {stripsComments} from "@tsed/ts-doc/src/utils/strips.js"; | ||
|
||
export default { | ||
name: "codeHighlight", | ||
trim: false, | ||
method(overview, symbolName, deprecated) { | ||
return {code: stripsComments(overview | ||
.replace(/( )+#private;\n/gi, "")) | ||
.replace(/\n( )+\n/gi, '\n'), deprecated}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
meta: | ||
- name: keywords | ||
description: api typescript node.js documentation <%- symbol.symbolName %> <%- symbol.symbolType %> | ||
--- | ||
# <%- symbol.symbolLabel %> <%- symbol.symbolName %> | ||
|
||
<%- components.symbolSummary(symbol) %> | ||
<% if(symbol.overview) { %> | ||
## Overview | ||
<%- components.codeHighlight(symbol.overview, symbol.symbolName) %> | ||
<% } | ||
if (hasParams) { %> | ||
<%- components.symbolParams(params, symbol.overview) %> | ||
<% } | ||
if (description) { %> | ||
<!-- Description --> | ||
## Description | ||
<%- description %> | ||
<% } | ||
if (symbol.members.length) { %> | ||
<!-- Members --> | ||
<%- components.symbolMembers(symbol) %> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export default { | ||
name: "page", | ||
trim: false, | ||
method(symbol) { | ||
let params = [], | ||
hasParams = false; | ||
let description = symbol.description || ""; | ||
|
||
if (symbol.symbolType === "function" || symbol.symbolType === "decorator") { | ||
params = symbol.getParams(); | ||
hasParams = params.length && symbol.overview.match(/\((.*)\):/); | ||
} | ||
|
||
return { | ||
params, | ||
hasParams, | ||
symbol, | ||
description | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<%- components.symbolHeader(symbol) %> | ||
<!-- summary --> | ||
<%- components.symbolSummary(symbol) %> | ||
<!-- overview --> | ||
<% if(symbol.overview) { %> | ||
|
||
### Overview | ||
|
||
<%- components.codeHighlight(symbol.overview, symbol.symbolName) %> | ||
<% } %> | ||
<!-- Parameters --> | ||
<% if (hasParams) { %> | ||
<%- components.symbolParams(params, symbol.overview) %> | ||
<% } %> | ||
<!-- Description --> | ||
<% if (description) { %> | ||
|
||
### Description | ||
|
||
<%- description %> | ||
<% } %> | ||
<!-- Members --> | ||
<% if (symbol.members.length) { %> | ||
<%- components.symbolMembers(symbol) %> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<Badge text="<%- symbol.symbolLabel %>" type="<%- symbol.symbolType %>"/> <%- labels.map((label) => components.symbolLabel(label)).join(' ') %> |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default { | ||
name: "symbolHeader", | ||
trim: true, | ||
method(symbol) { | ||
const ignoreLabels = ["type", "returns", "decorator", "param", "constructor"]; | ||
const id = symbol.symbolName.replace(/ /gi, "").toLowerCase(); | ||
let isPrivateAdded; | ||
|
||
const labels = (symbol.labels || []) | ||
.filter((label) => ignoreLabels.indexOf(label.key) === -1) | ||
.filter((label) => { | ||
if (label.key === "private" && !isPrivateAdded) { | ||
isPrivateAdded = true; | ||
return true; | ||
} | ||
if (label.key === "private") { | ||
return !isPrivateAdded; | ||
} | ||
return true; | ||
}); | ||
|
||
return { | ||
id, | ||
symbol, | ||
labels | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<Badge text="<%- label.key %>" title="<%- label.value %>" type="<%- label.key %>"/> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
name: "symbolLabel", | ||
trim: true, | ||
method(label) { | ||
return {label}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## <%- title %> | ||
|
||
<%- components.codeHighlight(member.overview.trim(), undefined) %> | ||
<% if (hasParams) { %> | ||
<%- components.symbolParams(member.params, member.overview) %> | ||
<% } %> | ||
<% if (member.description) { %> | ||
<%- member.description %> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default { | ||
name: "symbolMember", | ||
method(member) { | ||
let deprecated = false; | ||
const hasParams = member.params.length && member.overview.match(/\((.*)\):/); | ||
|
||
if (member.labels) { | ||
if (member.labels.find((k) => k.key === "deprecated")) { | ||
deprecated = true; | ||
} | ||
} | ||
|
||
const title = member.overview.match(/(.*)(\(|\?|=|:)+/) | ||
|
||
return { | ||
title: title ? title[1] | ||
.split("(")[0] | ||
.split("<")[0] | ||
.trim() : "", | ||
member, | ||
deprecated, | ||
hasParams | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%# Constructor %> | ||
<% if (hasConstructor) { %> | ||
## Constructor | ||
<% if (hasConstructorOverview) { %> | ||
<%- components.codeHighlight(construct.overview) %> | ||
<% } %> | ||
<% if (construct.description) { %> | ||
<%- construct.description %> | ||
<% } %> | ||
<% } %> | ||
<% if (members.length) { %> | ||
<% members.forEach((member, index, map) => { %> | ||
<%- components.symbolMember(member) %> | ||
<% }) %> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default { | ||
name: "symbolMembers", | ||
trim: false, | ||
method(symbol) { | ||
const flattenMembers = symbol.getMembers(); | ||
const construct = flattenMembers.filter((member) => member.overview.match("constructor"))[0]; | ||
const hasConstructor = construct && (construct.description || !construct.overview.match("constructor()")); | ||
let hasConstructorOverview = hasConstructor && construct.overview.match("constructor()"); | ||
const members = flattenMembers | ||
.filter((member) => !member.overview.includes("#private")) | ||
.filter((member) => !member.overview.match("constructor")); | ||
|
||
return { | ||
hasConstructor, | ||
hasConstructorOverview, | ||
members, | ||
construct | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
<% params.forEach(param => { %> | ||
- **<%- param.paramKey %>** (<%- param.type %>): <%- param.description %> | ||
<% }) %> |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
export default { | ||
name: "symbolParams", | ||
trim: false, | ||
method(params, overview) { | ||
const signatureMatch = overview.match(/\((.*)\):/); | ||
const signature = signatureMatch[1] + ","; | ||
|
||
params = params.map((param) => { | ||
const matched = signature.match(new RegExp(`${param.paramKey}(\\?)?:?(.[^,]+),`)); | ||
const type = (param.type || matched[2] ? matched[2].trim() : "") | ||
.split("|") | ||
.map((type) => { | ||
// type = bindSymbols(type.trim(), ""); | ||
|
||
// if (type.startsWith("<") && type.endsWith(">")) { | ||
// return type; | ||
// } | ||
|
||
return `\`${type.trim()}\``.trim(); | ||
}) | ||
.join(" | "); | ||
|
||
const description = (matched[1] ? "Optional. " : "") + param.description.replace(/Optional\.?/gi, "").trim(); | ||
|
||
return { | ||
param, | ||
signature, | ||
paramKey: param.paramKey, | ||
type: type, | ||
description | ||
}; | ||
}); | ||
|
||
return { | ||
params | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Usage | ||
|
||
```typescript | ||
import { <%- symbol.symbolName %> } from "<%- symbol.importFrom %>"; | ||
``` | ||
|
||
> See [<%- symbol.relativePath %>](<%- symbol.githubUrl %>). |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
name: "symbolSummary", | ||
trim: false, | ||
method(symbol) { | ||
return { | ||
symbol | ||
}; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {defineLoader} from "vitepress"; | ||
import * as fs from "node:fs/promises"; | ||
import {mapApiReferences} from "@tsed/vitepress-theme/composables/api/mappers/mapApiReferences"; | ||
import type {ApiResponse} from "@tsed/vitepress-theme/composables/api/interfaces/Api"; | ||
|
||
export interface Data extends ApiResponse { | ||
// data type | ||
} | ||
|
||
declare const data: Data; | ||
export {data}; | ||
|
||
export default defineLoader({ | ||
watch: ["./public/api.json"], | ||
async load(watchedFiles) { | ||
// fetch remote data | ||
const response = JSON.parse(await fs.readFile(watchedFiles[0], {encoding: "utf-8"})); | ||
|
||
return mapApiReferences(response); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
layout: page | ||
meta: | ||
- name: description | ||
content: Api Reference of Ts.ED. Use decorator to build your model and map data. | ||
- name: keywords | ||
content: api reference model decorators ts.ed express typescript node.js javascript jsonschema json mapper serialization deserialization | ||
--- | ||
|
||
<script setup> | ||
import {data} from './api.data'; | ||
</script> | ||
|
||
<Api :modules="data.modules" :symbol-types="data.symbolTypes" /> |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.