Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Di inject context props #2862

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,3 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn docs:publish
# publish-refs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
# - name: Install dependencies
# run: yarn install --immutable --network-timeout 500000
# - name: Build pages
# env:
# CI: true
# run: yarn api:build && yarn vitepress:ref:build
# - name: Publish pages
# env:
# CI: true
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# run: yarn docs:publish
20 changes: 0 additions & 20 deletions docs-references/.vuepress/config.js

This file was deleted.

14 changes: 0 additions & 14 deletions docs-references/readme.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/.templates/code-highlight/code-highlight.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```ts
<%- code %>
```
11 changes: 11 additions & 0 deletions docs/.templates/code-highlight/code-highlight.js
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};
}
};
30 changes: 30 additions & 0 deletions docs/.templates/page/page.ejs
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) %>
<% } %>
21 changes: 21 additions & 0 deletions docs/.templates/page/page.js
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
};
}
};
25 changes: 25 additions & 0 deletions docs/.templates/page/page.old
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) %>
<% } %>
1 change: 1 addition & 0 deletions docs/.templates/symbol-header/symbol-header.ejs
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(' ') %>
28 changes: 28 additions & 0 deletions docs/.templates/symbol-header/symbol-header.js
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
};
}
};
1 change: 1 addition & 0 deletions docs/.templates/symbol-label/symbol-label.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Badge text="<%- label.key %>" title="<%- label.value %>" type="<%- label.key %>"/>
7 changes: 7 additions & 0 deletions docs/.templates/symbol-label/symbol-label.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
name: "symbolLabel",
trim: true,
method(label) {
return {label};
}
};
9 changes: 9 additions & 0 deletions docs/.templates/symbol-member/symbol-member.ejs
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 %>
<% } %>
26 changes: 26 additions & 0 deletions docs/.templates/symbol-member/symbol-member.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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()
.replace("?", "") : "",
member,
deprecated,
hasParams
};
}
};
19 changes: 19 additions & 0 deletions docs/.templates/symbol-members/symbol-members.ejs
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) %>
<% }) %>
<% } %>
20 changes: 20 additions & 0 deletions docs/.templates/symbol-members/symbol-members.js
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
};
}
};
6 changes: 6 additions & 0 deletions docs/.templates/symbol-params/symbol-params.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<% params.forEach(param => { %>

- **<%- param.paramKey %>** (<%- param.type %>): <%- param.description %>

<% }) %>
39 changes: 39 additions & 0 deletions docs/.templates/symbol-params/symbol-params.js
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
};
}
};
7 changes: 7 additions & 0 deletions docs/.templates/symbol-summary/symbol-summary.ejs
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 %>).
9 changes: 9 additions & 0 deletions docs/.templates/symbol-summary/symbol-summary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
name: "symbolSummary",
trim: false,
method(symbol) {
return {
symbol
};
}
};
19 changes: 11 additions & 8 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ export default defineConfig({
// ['link', { rel: 'icon', type: 'image/svg+xml', href: '/tsed.svg' }],
["link", {rel: "icon", type: "image/png", href: "/tsed-og.png"}],
["link", {rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon"}],
["link", {rel: "icon", href: "/favicon.ico", type: "apple-touch-icon"}],
["link", {rel: "icon", href: "/apple-touch-icon.png", type: "image/x-icon", sizes: "180x180"}],
["link", {rel: "icon", href: "/favicon-32x32.png", type: "image/png", sizes: "32x32"}],
["link", {rel: "icon", href: "/favicon-16x16.png", type: "image/png", sizes: "16x16"}],
["link", {rel: "icon", href: "/icon512_maskable.png", type: "apple-touch-icon"}],
["link", {rel: "icon", href: "/icon512_maskable.png", type: "image/x-icon", sizes: "512x512"}],
["meta", {name: "theme-color", content: "#5f67ee"}],
["meta", {property: "og:type", content: "website"}],
["meta", {property: "og:locale", content: "en"}],
Expand All @@ -31,12 +29,12 @@ export default defineConfig({
themeConfig: {
logo: "/tsed.svg",
siteTitle: false,
apiUrl: "https://tsed.io/api.json",
apiRedirectUrl: "https://api-docs.tsed.io",
apiUrl: "/api.json",
apiRedirectUrl: "",
repo: "tsedio/tsed",
githubProxyUrl: "https://api.tsed.io/rest/github/tsedio/tsed",
editLink: {
pattern: "https://github.com/tsedio/tsed-website/edit/main/docs/:path"
pattern: "https://github.com/tsedio/tsed/edit/main/docs/:path"
},
search: {
provider: "algolia",
Expand Down Expand Up @@ -163,7 +161,8 @@ export default defineConfig({
link: `/docs/testing`
},
{text: "Upload files", link: "/docs/upload-files"},
{text: "Customize 404", link: "/docs/not-found-page"}
{text: "Customize 404", link: "/docs/not-found-page"},
{text: "Api references", link: "/api"},
]
},
{
Expand Down Expand Up @@ -433,6 +432,10 @@ export default defineConfig({
{
text: "Customize 404",
link: "/docs/not-found-page"
},
{
text: "Api references",
link: "/api"
}
]
}
Expand Down
Loading
Loading