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

Merge pdf #2751

Merged
merged 12 commits into from
May 9, 2023
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
32 changes: 16 additions & 16 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Publish docs via GitHub Pages
env:
ACTIONTEST: community
ACTIONTEST: master
# branch name, like master, 2.4
on:
push:
branches: # hard code branch name
- community
- master

jobs:
prepare:
Expand All @@ -27,7 +27,7 @@ jobs:
id: set-matrix
run: |
import yaml, os, json
with open('database_edition.yml', 'r') as file:
with open('./database_edition.yml', 'r') as file:
mkdocs = yaml.safe_load(file)
database_edition = mkdocs.get('database_edition', '')
print(f"database_edition: {database_edition}") # Print the variable for debugging
Expand Down Expand Up @@ -61,27 +61,29 @@ jobs:

- name : prepare
run: sh ./prepare.sh

# if 'both', set each file 'community' and 'enterprise' seperately.
- name: Update database_edition.yml
run: |
import yaml
with open('database_edition.yml', 'r') as file:
mkdocs = yaml.safe_load(file)
database_edition = mkdocs.get('database_edition', '')
import yaml
with open('./database_edition.yml', 'r') as file:
content = yaml.safe_load(file)
content['database_edition'] = f"${{ matrix.database_edition }}"
with open('./database_edition.yml', 'w') as file:
yaml.dump(content, file)
shell: python

- name: Git Config
run: git config user.name whitewum && git config user.email min.wu@vesoft.com

- name: save tmp files
run: |
cp -f *.json /tmp/
cp -f *.yml /tmp/
cp -f *versions.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json
ls /tmp/ -ltr
- name: mike
run: |
python ./scripts/conditional_render.py
python ./scripts/conditional_yml.py
python ./scripts/conditional_pdf.py
git fetch origin gh-pages --depth=1 # fix mike's CI update
mike deploy ${{ env.ACTIONTEST }} -p --rebase
mike list
Expand All @@ -94,10 +96,8 @@ jobs:
run: |
import yaml, json
new_content = {"version": "${{ env.ACTIONTEST }}", "title": "${{ env.ACTIONTEST }}", "aliases": []}
with open('/tmp/database_edition.yml', 'r') as file:
mkdocs = yaml.safe_load(file)
database_edition = mkdocs.get('database_edition', '')
filename = "/tmp/" + database_edition + "_versions.json"
# the only place read from /tmp/
filename = "/tmp/" + f"${{ matrix.database_edition }}" + "_versions.json"
with open(filename, 'r') as infile:
json_data = json.load(infile)
found = False
Expand All @@ -107,7 +107,7 @@ jobs:
break
if not found:
json_data.append(new_content)
with open('versions.json', 'w') as outfile:
with open('./versions.json', 'w') as outfile:
json.dump(json_data, outfile, indent=2)
shell: python
- name: Compress
Expand Down
6 changes: 5 additions & 1 deletion database_edition.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
database_edition: community
database_edition: both
# Copy from the folowing words. Not write the word by your self
# community
# enterprise
# both
26 changes: 13 additions & 13 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,16 @@ plugins:
# Exclude files with regular expressions (regexes)
# regex:
# - '.*\.(tmp|bin|tar)$'

# modify when release:
# - with-pdf:
# copyright: 2023 vesoft Inc.
# cover_subtitle: master
# author: 吴敏,梁振亚,黄凤仙,李泓臻
# cover: true
# back_cover: true
# cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png'
# output_path: pdf/NebulaGraph-CN.pdf

# nav.pdf.begin
- with-pdf:
copyright: 2023 vesoft Inc.
cover_subtitle: master
author: 吴敏,梁振亚,黄凤仙,李泓臻
cover: true
back_cover: true
cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png'
output_path: pdf/NebulaGraph-CN.pdf
# nav.pdf.end
extra_javascript:
- js/version-select.js
- js/config.js
Expand Down Expand Up @@ -893,5 +892,6 @@ nav:
- 年表: 20.appendix/history.md
- 思维导图: 20.appendix/mind-map.md
- 错误码: 20.appendix/error-code.md

# - PDF: ./pdf/NebulaGraph-CN.pdf
# nav.pdf.begin
- PDF: ./pdf/NebulaGraph-CN.pdf
# nav.pdf.end
14 changes: 2 additions & 12 deletions pdf.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
# modify when release:
- PDF: ./pdf/NebulaGraph-CN.pdf

plugins:
- with-pdf:
copyright: 2023 vesoft Inc.
cover_subtitle: master
author: 吴敏,周瑶,梁振亚,黄凤仙
cover: true
back_cover: true
cover_logo: 'https://cloud-cdn.nebula-graph.com.cn/nebula-for-pdf.png'
output_path: pdf/NebulaGraph-CN.pdf
withpdf: False
# True or False. case sensitive
42 changes: 0 additions & 42 deletions scripts/auto_release.py

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/conditional_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import re
import yaml

def process_mkdocs_yml(mkdocs_yml_path, withpdf):
with open(mkdocs_yml_path, 'r', encoding='utf-8') as f:
content = f.read()
if withpdf == True:
content = re.sub(
r'#\s*nav\.pdf\.begin(.*?)#\s*nav\.pdf\.end',
'\\1', content, flags=re.DOTALL)
elif withpdf == False:
print("remove pdf")
content = re.sub(
r'#\s*nav\.pdf\.begin(.*?)#\s*nav\.pdf\.end',
'', content, flags=re.DOTALL)
with open(mkdocs_yml_path, 'w', encoding='utf-8') as f:
f.write(content)
print(content)

if __name__ == '__main__':
pdf_yml_path = 'pdf.yml'
with open(pdf_yml_path, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
withpdf = config.get("withpdf", "")
print(withpdf)
if (withpdf != True) and (withpdf != False):
raise ValueError("Invalid value for pdf parameter: {}".format(withpdf))
process_mkdocs_yml('mkdocs.yml', withpdf)