Skip to content

Commit ab0c963

Browse files
authored
Merge pull request #56 from akhuoa/docs
API Documentation
2 parents 4fd7286 + 8f2ec73 commit ab0c963

14 files changed

+6042
-8664
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy Docs to Pages
2+
3+
on:
4+
# Runs on pushes targeting the `docs` branch and `main` branch.
5+
push:
6+
branches: ["docs", "main"]
7+
8+
# Allows you to run this workflow manually from the Actions tab.
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages.
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
# concurrency:
20+
# group: pages
21+
# cancel-in-progress: false
22+
23+
jobs:
24+
# Build the documentation.
25+
build:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '18.17.1'
35+
cache: npm
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Build with VitePress
41+
run: |
42+
npm run docs:build
43+
touch docs/.vitepress/dist/.nojekyll
44+
45+
- name: Upload artifact
46+
uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: ./docs/.vitepress/dist
49+
50+
# Deploy the documentation.
51+
deploy:
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
56+
runs-on: ubuntu-latest
57+
58+
needs: build
59+
60+
steps:
61+
- name: Deploy to Github Pages
62+
id: deployment
63+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ pnpm-debug.log*
2323
*.njsproj
2424
*.sln
2525
*.sw?
26+
27+
# API docs
28+
docs/.vitepress/dist
29+
docs/.vitepress/cache
30+
docs/components

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ You can now use the SimulationVuer in your Vue template as follows:
4545
<SimulationVuer :apiLocation="apiLocation" :id=123 />
4646
```
4747

48-
where `apiLocation` is the URL to the API location and `id` the id of the dataset.
48+
where `apiLocation` is the URL to the API location and `id` the id of the simulation-based dataset.
4949

5050
## Project setup
5151

@@ -79,3 +79,15 @@ npm run build-bundle
7979

8080
SimulationVuer is now being developed as a Vue 3 component only.
8181
The [Vue 2 version of SimulationVuer](https://github.com/ABI-Software/simulationvuer/tree/vue2) is not maintained anymore.
82+
83+
## Documentation
84+
85+
The documentation is written using [VitePress](https://vitepress.dev/) and [vuese](https://github.com/vuese/vuese#readme), and it can be found in the `docs` folder.
86+
87+
#### To run in local development mode
88+
89+
```bash
90+
npm run docs:watch
91+
```
92+
93+
This will start the documentation server with [VitePress](https://vitepress.dev/) on port `5173`: http://localhost:5173/simulationvuer/.

docs/.vitepress/config.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { defineConfig } from 'vitepress'
2+
import Components from 'unplugin-vue-components/vite'
3+
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
4+
5+
const versionNumber = process.env.npm_package_version
6+
7+
// https://vitepress.dev/reference/site-config
8+
export default defineConfig({
9+
title: "SimulationVuer",
10+
description: "API documentation for SimulationVuer",
11+
base: '/simulationvuer/',
12+
themeConfig: {
13+
// https://vitepress.dev/reference/default-theme-config
14+
nav: [
15+
{ text: 'Home', link: '/' },
16+
{
17+
text: 'API Reference',
18+
link: '/components/SimulationVuer'
19+
}
20+
],
21+
22+
sidebar: [
23+
{
24+
text: 'Live Demo',
25+
link: '/demo'
26+
},
27+
{
28+
text: 'API Reference',
29+
link: '/components/SimulationVuer'
30+
},
31+
{
32+
text: 'Version',
33+
items: [
34+
{
35+
text: `${versionNumber}`
36+
}
37+
]
38+
}
39+
],
40+
41+
socialLinks: [
42+
{ icon: 'github', link: 'https://github.com/ABI-Software/simulationvuer' }
43+
]
44+
},
45+
markdown: { attrs: { disable: true } },
46+
vite: {
47+
css: {
48+
preprocessorOptions: {
49+
scss: {
50+
additionalData: `@use '../src/assets/styles' as *;`
51+
},
52+
},
53+
},
54+
plugins: [
55+
Components({
56+
// Allow auto load markdown components under `./src/components/`.
57+
extensions: ['vue'],
58+
// Allow auto import and register the components used in markdown.
59+
include: [/\.vue$/, /\.vue\?vue/],
60+
resolvers: [
61+
ElementPlusResolver({
62+
importStyle: 'css',
63+
}),
64+
],
65+
}),
66+
]
67+
}
68+
})

docs/.vitepress/theme/custom.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Modify content styles for the desktop view. */
2+
@media (min-width: 1280px) {
3+
.VPContent .VPDoc.has-aside {
4+
& .content-container {
5+
max-width: none;
6+
}
7+
8+
.content-container .vp-doc {
9+
& table {
10+
overflow: unset;
11+
}
12+
13+
& table thead {
14+
position: sticky;
15+
top: 64px; /* Navigation height. */
16+
17+
& th {
18+
background-color: var(--vp-c-gray-1);
19+
}
20+
}
21+
22+
& table tr {
23+
th, td {
24+
vertical-align: top;
25+
}
26+
27+
th:first-child,
28+
td:first-child {
29+
width: 10%;
30+
text-wrap: nowrap;
31+
}
32+
33+
/* Description column. */
34+
th:nth-child(2),
35+
td:nth-child(2) {
36+
width: 40%;
37+
}
38+
39+
th:nth-child(3),
40+
td:nth-child(3) {
41+
width: 10%;
42+
}
43+
44+
th:nth-child(4),
45+
td:nth-child(4) {
46+
width: 10%;
47+
}
48+
49+
th:last-child,
50+
td:last-child {
51+
width: 20%;
52+
word-wrap: break-word;
53+
word-break: break-word;
54+
}
55+
}
56+
}
57+
}
58+
}

docs/.vitepress/theme/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import DefaultTheme from "vitepress/theme";
2+
import "./custom.css";
3+
4+
export default DefaultTheme;

docs/demo-styles.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.demo-map-container {
2+
width: 100%;
3+
height: 0;
4+
padding-bottom: 75%;
5+
border: 1px solid var(--vp-c-divider);
6+
position: relative;
7+
z-index: 1; /* Just for the demo, to prevent tooltips from going out of the container. */
8+
}
9+
10+
.demo-map-container-inner {
11+
width: 100%;
12+
height: 100%;
13+
position: absolute;
14+
}
15+
16+
.flatmap-container {
17+
overflow: hidden;
18+
}
19+
20+
.bottom-right-control {
21+
display: flex;
22+
flex-direction: row;
23+
gap: 8px;
24+
}
25+
26+
.zoomOut,
27+
.fitWindow {
28+
padding-left: 0px !important;
29+
}

docs/demo.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SimulationVuer Live Demo
2+
3+
## Live Demo
4+
5+
<div class="demo-map-container">
6+
<div class="demo-map-container-inner">
7+
<ClientOnly>
8+
<SimulationVuer
9+
:apiLocation="apiLocation"
10+
:id="id"
11+
/>
12+
</ClientOnly>
13+
</div>
14+
</div>
15+
16+
<script setup>
17+
import { defineClientComponent } from "vitepress";
18+
import "./demo-styles.css";
19+
20+
const SimulationVuer = defineClientComponent(() => {
21+
return import("../src/components/SimulationVuer.vue");
22+
})
23+
</script>
24+
25+
<script>
26+
export default {
27+
data: function() {
28+
return {
29+
apiLocation: import.meta.env.VITE_API_LOCATION,
30+
id: 135,
31+
};
32+
}
33+
}
34+
</script>
35+
36+
## Code Preview
37+
38+
```js-vue
39+
<div class="your-outer-container">
40+
<SimulationVuer
41+
:apiLocation="apiLocation"
42+
:id="id"
43+
/>
44+
</div>
45+
46+
<script>
47+
import { SimulationVuer } from "@abi-software/simulationvuer";
48+
49+
export default {
50+
components: { SimulationVuer },
51+
data: function () {
52+
return {
53+
apiLocation: API_LOCATION,
54+
id: 135,
55+
}
56+
}
57+
}
58+
</script>
59+
```

docs/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
# https://vitepress.dev/reference/default-theme-home-page
3+
layout: home
4+
5+
hero:
6+
name: "SimulationVuer"
7+
text: "API documentation"
8+
tagline: SimulationVuer is a Vue component used in the SPARC portal to run some simulation-based datasets.
9+
actions:
10+
- theme: brand
11+
text: API Reference
12+
link: /components/SimulationVuer
13+
- theme: alt
14+
text: Demo
15+
link: /demo
16+
---

0 commit comments

Comments
 (0)