Skip to content

Commit 1c6cfbc

Browse files
sanych-sunOleksandr Poliakov
and
Oleksandr Poliakov
authored
ApiDocs with docfx (#44)
Co-authored-by: Oleksandr Poliakov <[email protected]>
1 parent 55255a1 commit 1c6cfbc

File tree

15 files changed

+172
-34
lines changed

15 files changed

+172
-34
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ src/packages
6363
.dotnet
6464

6565
# Other
66+
.config
6667
artifacts
6768
packages
6869
/tools

Diff for: apidocs/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.manifest
2+
api/**.yml

Diff for: apidocs/api/MongoDB.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
redirect_url: ../index.html
3+
---
File renamed without changes.

Diff for: docfx_project/docfx.json renamed to apidocs/docfx.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121
"build": {
2222
"content": [
2323
{
24-
"files": ["api/**.yml", "api/index.md"]
24+
"files": ["api/**.yml", "api/index.md", "api/MongoDB.md"]
2525
},
2626
{
27-
"files": ["articles/**.md", "articles/**/toc.yml", "toc.yml", "*.md"]
27+
"files": ["*.md"]
2828
}
2929
],
3030
"resource": [
3131
{
32-
"files": ["images/**", "images/mongodb-logo.svg"]
32+
"files": ["images/**"]
3333
}
3434
],
35-
"output": "_site",
3635
"globalMetadataFiles": [],
3736
"fileMetadataFiles": [],
38-
"template": ["default", "modern"],
37+
"template": ["default", "modern", "mongo-apidocs"],
3938
"postProcessors": [],
4039
"keepFileLink": false,
4140
"disableGitFeatures": false,
4241
"globalMetadata": {
4342
"_appTitle": "MongoDB EF Core Provider API Reference",
4443
"_appFooter": "&copy; 2023 MongoDB, Inc.",
45-
"_appLogoPath": "images/mongodb-logo.svg"
44+
"_appLogoPath": "images/mongodb-logo.svg",
45+
"_disableContribution": "true"
4646
}
4747
}
4848
}

Diff for: docfx_project/images/mongodb-logo.svg renamed to apidocs/images/mongodb-logo.svg

+4-3
Loading

Diff for: apidocs/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
redirect_url: api/index.html
3+
---

Diff for: apidocs/mongo-apidocs/public/main.css

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
:root {
2+
--bs-font-sans-serif: 'Euclid Circular A','Helvetica Neue',Helvetica,Arial,sans-serif;
3+
--bs-font-monospace: "Source Code Pro", Menlo, monospace;
4+
}
5+
6+
h1, h2, h3 {
7+
font-family: 'MongoDB Value Serif','Times New Roman',serif;
8+
color: rgb(0, 104, 74);
9+
font-weight: bold;
10+
}
11+
12+
dt {
13+
font-weight: normal;
14+
}
15+
16+
@font-face {
17+
font-family: Euclid Circular A;
18+
src: url(https://static.mongodb.com/com/fonts/EuclidCircularA-Regular-WebXL.woff2) format('woff2');
19+
font-weight: normal;
20+
font-display: swap;
21+
}
22+
23+
@font-face {
24+
font-family: Euclid Circular A;
25+
src: url(https://static.mongodb.com/com/fonts/EuclidCircularA-Medium-WebXL.woff2) format('woff2');
26+
font-weight: 500;
27+
font-display: swap;
28+
}
29+
30+
@font-face {
31+
font-family: MongoDB Value Serif;
32+
src: url(https://static.mongodb.com/com/fonts/MongoDBValueSerif-Regular.woff2) format('woff2');
33+
font-weight: normal;
34+
font-display: swap;
35+
}
36+
37+
@font-face {
38+
font-family: MongoDB Value Serif;
39+
src: url(https://static.mongodb.com/com/fonts/MongoDBValueSerif-Medium.woff2) format('woff2');
40+
font-weight: 500;
41+
font-display: swap;
42+
}
43+
44+
@font-face {
45+
font-family: MongoDB Value Serif;
46+
src: url(https://static.mongodb.com/com/fonts/MongoDBValueSerif-Bold.woff2) format('woff2');
47+
font-weight: bold;
48+
font-display: swap;
49+
}
50+
51+
@font-face {
52+
font-family: Source Code Pro;
53+
src: url(https://static.mongodb.com/com/fonts/SourceCodePro-Regular.ttf) format('truetype');
54+
font-weight: normal;
55+
font-display: swap;
56+
}
57+
58+
@font-face {
59+
font-family: Source Code Pro;
60+
src: url(https://static.mongodb.com/com/fonts/SourceCodePro-Medium.ttf) format('truetype');
61+
font-weight: 500;
62+
font-display: swap;
63+
}

Diff for: docfx_project/.gitignore

-6
This file was deleted.

Diff for: docfx_project/api/.gitignore

-5
This file was deleted.

Diff for: docfx_project/index.md

-1
This file was deleted.

Diff for: docfx_project/toc.yml

-3
This file was deleted.

Diff for: evergreen/build-apidocs.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
if [ -z "$PACKAGE_VERSION" ]; then
5+
PACKAGE_VERSION=$(sh ./evergreen/generate-version.sh)
6+
echo Calculated PACKAGE_VERSION value: "$PACKAGE_VERSION"
7+
fi
8+
9+
echo "Configure dotnet cli to use local manifest"
10+
dotnet new tool-manifest --force
11+
12+
echo "Installing docfx tool"
13+
dotnet tool install docfx --version "2.72.1" --local --verbosity q
14+
15+
echo "Building the api-docs"
16+
dotnet tool run docfx metadata ./apidocs/docfx.json --property ProduceReferenceAssembly=true
17+
dotnet tool run docfx build ./apidocs/docfx.json -o:./artifacts/apidocs/"$PACKAGE_VERSION"

Diff for: evergreen/evergreen.yml

+57-10
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@ functions:
3838
shell: bash
3939
working_dir: mongo-efcore-provider
4040
script: |
41-
echo "${BUILD_TARGET}"
4241
# Get the current unique version of this checkout
4342
if [ "${is_patch}" = "true" ]; then
4443
CURRENT_VERSION=$(git describe)-patch-${version_id}
4544
else
4645
CURRENT_VERSION=latest
4746
fi
4847
49-
if [ "${BUILD_TARGET}" != "tests" ]; then
50-
PACKAGE_VERSION=$(BUILD_TARGET="${BUILD_TARGET}" sh ./evergreen/packages-version.sh)
51-
fi
48+
if [ "${BUILD_TARGET}" = "release" ]; then
49+
PACKAGE_VERSION=$(BUILD_TARGET="${BUILD_TARGET}" sh ./evergreen/generate-version.sh)
50+
fi
5251
5352
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
5453
export DOTNET_SDK_PATH="$(pwd)/../.dotnet"
@@ -290,6 +289,35 @@ functions:
290289
remote_file: ${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
291290
bucket: ${aws_upload_bucket}
292291

292+
build-apidocs:
293+
- command: shell.exec
294+
params:
295+
shell: bash
296+
working_dir: mongo-efcore-provider
297+
script: |
298+
${PREPARE_SHELL}
299+
if ! [[ "$PACKAGE_VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then
300+
echo "Skip api docs generating for the patch release"
301+
exit 0
302+
fi
303+
./evergreen/build-apidocs.sh
304+
305+
upload-apidocs:
306+
- command: shell.exec
307+
params:
308+
shell: bash
309+
working_dir: mongo-efcore-provider
310+
env:
311+
GITHUB_USER: ${github_user}
312+
GITHUB_APIKEY: ${github_apikey}
313+
script: |
314+
${PREPARE_SHELL}
315+
if ! [[ "$PACKAGE_VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then
316+
echo "Skip api docs generating for the patch release"
317+
exit 0
318+
fi
319+
./evergreen/upload-apidocs.sh
320+
293321
pre:
294322
- func: fetch-source
295323
- func: prepare-resources
@@ -324,6 +352,11 @@ tasks:
324352
PACKAGE_ID: "MongoDB.EntityFrameworkCore"
325353
- func: packages-smoke-tests
326354

355+
- name: generate-apidocs
356+
commands:
357+
- func: build-apidocs
358+
- func: upload-apidocs
359+
327360
- name: push-packages
328361
commands:
329362
- func: download-package
@@ -417,10 +450,10 @@ axes:
417450
display_name: "tests"
418451
variables:
419452
BUILD_TARGET: "tests"
420-
- id: "package"
421-
display_name: "package"
453+
- id: "release"
454+
display_name: "release"
422455
variables:
423-
BUILD_TARGET: "package"
456+
BUILD_TARGET: "release"
424457

425458
buildvariants:
426459
- matrix_name: main-tests
@@ -453,7 +486,7 @@ buildvariants:
453486

454487
- matrix_name: pack-packages
455488
matrix_spec:
456-
build-target: "package"
489+
build-target: "release"
457490
display_name: "Package Pack"
458491
run_on: ubuntu2004-small
459492
tags: ["pack-packages", "release_tag"]
@@ -467,7 +500,7 @@ buildvariants:
467500
os: "*"
468501
driver: "latest"
469502
target_runtime: "*"
470-
build-target: "package"
503+
build-target: "release"
471504
display_name: "${target_runtime} smoke tests on ${os}"
472505
tags: ["package-tests", "release_tag"]
473506
tasks:
@@ -477,10 +510,22 @@ buildvariants:
477510
- name: pack-packages
478511
variant: .pack-packages
479512

513+
- matrix_name: generate-apidocs
514+
matrix_spec:
515+
build-target: "release"
516+
display_name: "Generate API Documentation"
517+
run_on: ubuntu2004-small
518+
tags: ["generate-apidocs", "release_tag"]
519+
tasks:
520+
- name: generate-apidocs
521+
git_tag_only: true
522+
depends_on:
523+
- name: packages-tests
524+
variant: .package-tests
480525

481526
- matrix_name: push-packages
482527
matrix_spec:
483-
build-target: "package"
528+
build-target: "release"
484529
display_name: "Package Push"
485530
run_on: ubuntu2004-small
486531
tags: ["push-packages", "release_tag"]
@@ -492,3 +537,5 @@ buildvariants:
492537
variant: .pack-packages
493538
- name: packages-tests
494539
variant: .package-tests
540+
- name: generate-apidocs
541+
variant: .generate-apidocs

Diff for: evergreen/upload-apidocs.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
DOCS_REPO="https://${GITHUB_USER}:${GITHUB_APIKEY}@github.com/mongodb/mongo-efcore-provider.git"
5+
6+
echo "Prepare github docs"
7+
git clone "$DOCS_REPO" ./gh-pages/ --branch gh-pages --single-branch
8+
9+
mkdir ./gh-pages/"$PACKAGE_VERSION"/
10+
cp -r ./artifacts/apidocs/"$PACKAGE_VERSION"/. ./gh-pages/"$PACKAGE_VERSION"/
11+
12+
cd ./gh-pages
13+
14+
git add --all
15+
git commit -m "Add $PACKAGE_VERSION Api docs" --author="Build Agent<[email protected]>"
16+
git push --repo="$DOCS_REPO"

0 commit comments

Comments
 (0)