Skip to content

Commit

Permalink
Doc API Cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Oct 6, 2023
1 parent 9b30ce7 commit 67706ac
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 228 deletions.
6 changes: 3 additions & 3 deletions api-generator/build-apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ if (project) {

child.type?.declaration?.signatures[0]?.parameters.map((param, index) => {
if (index !== 0) functionParameters += `, `;
functionParameters += `<span class="text-800">${param.name}</span>: ${param.type?.name}`;
functionParameters += `<span class="text-primary-700">${param.name}</span>: ${param.type?.name}`;
});

type += `\t <span class="text-900">${child.name}</span>: <span class="text-600">(${functionParameters}) &rArr; ${child.type?.declaration?.signatures[0]?.type?.name}</span>, <span class="text-500">// ${child.type?.declaration?.signatures[0]?.comment.summary[0]?.text}</span>\n`;
type += `\t <span class="ml-3 text-primary-700">${child.name}</span>: <span class="text-primary-500">(${functionParameters}) &rArr; ${child.type?.declaration?.signatures[0]?.type?.name}</span>, <span class="text-primary-300">// ${child.type?.declaration?.signatures[0]?.comment.summary[0]?.text}</span>\n`;
} else {
const childType = child.type.elementType ? child.type.elementType.name : child.type.name;

type += ` \t <span class="text-900">${child.name}</span>: <span class="text-600">${childType}</span>, <span class="text-500">// ${child.comment?.summary[0]?.text}</span>\n `;
type += ` \t <span class="ml-3 text-primary-700">${child.name}</span>: <span class="text-primary-500">${childType}</span>, <span class="text-primary-300">// ${child.comment?.summary[0]?.text}</span>\n `;
}
}
});
Expand Down
67 changes: 42 additions & 25 deletions assets/styles/layout/_doc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@

th {
border-bottom: 1px solid var(--surface-border);
padding: .75rem;
padding: .75rem 1rem;
text-align: left;
text-transform: capitalize;
}
Expand All @@ -270,37 +270,36 @@
}

td {
padding: .75rem;
padding: .75rem 1rem;
border-bottom: 1px solid var(--surface-border);
white-space: pre-wrap;
white-space: pre-line;
line-height: 1.5;
scroll-margin-top: 6.5rem;

&:first-child {
color: var(--primary-color);
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
}

.doc-option-type {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
color: var(--primary-500);
font-weight: 500;

> a {
color: var(--primary-500);

&:hover {
text-decoration: underline;
}
}

.doc-option-type-options-container {
display: flex;
align-items: center;
}

span.doc-option-type-options {
color: var(--primary-700);
}
}

&:first-child {
color: var(--primary-color);
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
&.doc-option-link {
&:hover {
text-decoration: underline;
}
}
}

.doc-option-name,
Expand All @@ -312,8 +311,9 @@
color: var(--highlight-text-color);
border-radius: 6px;
padding: 2px 6px;
font-weight: 400;
font-weight: 600;
font-style: normal;
white-space: nowrap;

.doc-option-link {
position: absolute;
Expand All @@ -326,8 +326,23 @@
}
}

&:hover {
.doc-option-name {
.doc-option-link {
display: inline;

&:hover {
opacity: 1;
}
}
}
}

.doc-option-default,
.doc-option-returnType {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
font-weight: 400;
font-style: normal;
display: flex;
border-width: 1px;
border-style: solid;
Expand All @@ -336,16 +351,18 @@
max-width: min-content;
}

&:hover {
.doc-option-name {
.doc-option-link {
display: inline;
.doc-option-parameter-name {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
color: var(--primary-700);
}

&:hover {
opacity: 1;
}
}
}
.doc-option-parameter-type {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
color: var(--primary-500);
}

.doc-option-params {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, Liberation Mono, monospace;
}

.doc-option-light {
Expand Down
12 changes: 7 additions & 5 deletions components/doc/DocApiTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
</template>

<template v-else-if="k === 'parameters'">
<span v-if="v.name" :class="{ 'font-medium text-600': label === 'Slots', 'doc-option-parameter-name': label === 'Emits' }"> {{ v.name }} : </span>
<template v-for="(value, i) in getType(v.type)" :key="value">
{{ i !== 0 ? ' | ' : '' }}<NuxtLink v-if="isLinkType(value)" :to="setLinkPath(value)" class="doc-option-link doc-option-parameter-type"> {{ value }} </NuxtLink>
<span v-else :class="{ 'doc-option-parameter-type': label === 'Emits' }" v-html="value"> </span>
</template>
<div class="doc-option-params">
<span v-if="v.name" :class="{ 'text-primary-700': label === 'Slots', 'doc-option-parameter-name': label === 'Emits' }"> {{ v.name }} : </span>
<template v-for="(value, i) in getType(v.type)" :key="value">
{{ i !== 0 ? ' | ' : '' }}<NuxtLink v-if="isLinkType(value)" :to="setLinkPath(value)" class="doc-option-link doc-option-parameter-type"> {{ value }} </NuxtLink>
<span v-else :class="{ 'doc-option-parameter-type': label === 'Emits' }" v-html="value"> </span>
</template>
</div>
</template>

<div v-else-if="k === 'default'" :id="id + '.' + k" :class="['doc-option-default', $appState.darkTheme ? 'doc-option-dark' : 'doc-option-light']">
Expand Down
Loading

0 comments on commit 67706ac

Please sign in to comment.