You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ki...@apache.org on 2020/08/07 19:37:10 UTC
[shardingsphere] branch master updated: Download PDF by Cayman
(#6696)
This is an automated email from the ASF dual-hosted git repository.
kimmking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b68e047 Download PDF by Cayman (#6696)
b68e047 is described below
commit b68e04753dcb5f03c531a1c8a8b88c989a1f623e
Author: CaymanHK <55...@users.noreply.github.com>
AuthorDate: Sat Aug 8 03:36:52 2020 +0800
Download PDF by Cayman (#6696)
* buildPDF by Cayman
* test buildPDF by Cayman
* buildPDF by Cayman
* set default index.html by Cayman
---
.github/workflows/buildPDF.yml | 57 ++++++++++++
.github/workflows/maven.yml | 3 +-
docs/document/Makefile | 20 ++++
docs/document/conf.py | 102 +++++++++++++++++++++
docs/document/generatePDF.sh | 74 +++++++++++++++
docs/document/requirements.txt | 1 +
docs/document/static/pdf/shadingsphere_docs_cn.pdf | Bin 0 -> 6696795 bytes
docs/document/static/pdf/shadingsphere_docs_en.pdf | Bin 0 -> 6230441 bytes
.../hugo-theme-learn/layouts/partials/menu.html | 13 ++-
9 files changed, 265 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/buildPDF.yml b/.github/workflows/buildPDF.yml
new file mode 100644
index 0000000..783efd9
--- /dev/null
+++ b/.github/workflows/buildPDF.yml
@@ -0,0 +1,57 @@
+name: build docs PDF
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - 'docs/document/content/**'
+jobs:
+ build:
+ # instal dependencies
+ name: publish PDF
+ # This job runs on Linux
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.7'
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install sphinx
+ sudo apt-get update -y
+ sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
+ sudo apt-get install texlive-xetex latex-cjk-all
+ sudo apt-get install pandoc
+ wget https://github.com/adobe-fonts/source-han-sans/raw/release/OTF/SourceHanSansSC.zip
+ wget https://github.com/adobe-fonts/source-han-serif/raw/release/OTF/SourceHanSerifSC_SB-H.zip
+ wget https://github.com/adobe-fonts/source-han-serif/raw/release/OTF/SourceHanSerifSC_EL-M.zip
+ unzip SourceHanSansSC.zip
+ unzip SourceHanSerifSC_EL-M.zip
+ unzip SourceHanSerifSC_SB-H.zip
+ sudo mv SourceHanSansSC SourceHanSerifSC_EL-M SourceHanSerifSC_SB-H /usr/share/fonts/opentype/
+ wget -O source-serif-pro.zip https://www.fontsquirrel.com/fonts/download/source-serif-pro
+ unzip source-serif-pro -d source-serif-pro
+ sudo mv source-serif-pro /usr/share/fonts/opentype/
+ wget -O source-sans-pro.zip https://www.fontsquirrel.com/fonts/download/source-sans-pro
+ unzip source-sans-pro -d source-sans-pro
+ sudo mv source-sans-pro /usr/share/fonts/opentype/
+ wget -O source-code-pro.zip https://www.fontsquirrel.com/fonts/download/source-code-pro
+ unzip source-code-pro -d source-code-pro
+ sudo mv source-code-pro /usr/share/fonts/opentype/
+ sudo fc-cache -f -v
+ - name: generate PDF
+ run: |
+ cd docs/document
+ bash generatePDF.sh cn
+ bash generatePDF.sh en
+ - name: commit PDF
+ run: |
+ git config user.name github-actions
+ git config user.email github-actions@github.com
+ git add *.pdf -f
+ git commit -m "Update PDF files"
+ git push -u origin master
\ No newline at end of file
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 70250f6..c65f6fe 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -32,7 +32,8 @@ jobs:
runs-on: macos-latest
steps:
- - uses: actions/checkout@v2
+ - name: Checkout
+ uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
diff --git a/docs/document/Makefile b/docs/document/Makefile
new file mode 100644
index 0000000..92dd33a
--- /dev/null
+++ b/docs/document/Makefile
@@ -0,0 +1,20 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS ?=
+SPHINXBUILD ?= sphinx-build
+SOURCEDIR = source
+BUILDDIR = _build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/document/conf.py b/docs/document/conf.py
new file mode 100644
index 0000000..7343d65
--- /dev/null
+++ b/docs/document/conf.py
@@ -0,0 +1,102 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# This file only contains a selection of the most common options. For a full
+# list see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+# -- Project information -----------------------------------------------------
+
+project = 'Apache ShardingSphere document'
+copyright = '2020, Apache ShardingSphere'
+author = 'Apache ShardingSphere'
+
+
+# -- General configuration ---------------------------------------------------
+# The master toctree document.
+master_doc = 'index'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.autosectionlabel',
+]
+
+pygments_style = 'sphinx'
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+source_suffix = ['.rst']
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = 'en_US'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+
+# -- Options for HTML output -------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'sphinx_rtd_theme'
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+latex_engine = 'xelatex'
+
+latex_elements = {
+ 'papersize': 'a4paper',
+ 'pointsize': '10pt',
+ 'figure_align': 'htbp',
+ 'classoptions': ',oneside',
+ 'passoptionstopackages': r'\PassOptionsToPackage{svgnames}{xcolor}',
+ 'fontpkg': r'''
+ \setmainfont{Source Serif Pro}
+ \setsansfont{Source Sans Pro}
+ \setmonofont{Source Code Pro}
+ ''',
+ 'preamble': r'''
+ \usepackage{ctex}
+ \setCJKmainfont[BoldFont=Source Han Serif SC SemiBold]{Source Han Serif SC}
+ \setCJKsansfont[BoldFont=Source Han Sans SC Medium]{Source Han Sans SC Normal}
+ \setCJKmonofont{Source Han Sans SC Normal}
+ \usepackage[draft]{minted}
+ \fvset{breaklines=true}
+ \setcounter{tocdepth}{3}
+ \usepackage[breaklinks]{hyperref}
+ ''',
+ 'fncychap': r'\usepackage[Bjornstrup]{fncychap}',
+ 'babel' : r'''
+ \usepackage{polyglossia}
+ \setmainlanguage{english}
+ ''',
+ 'printindex': r'\footnotesize\raggedright\printindex',
+ 'sphinxsetup':r'''
+ verbatimwithframe=false,
+ VerbatimColor={rgb}{0.95,0.95,0.92},
+ verbatimvisiblespace=\null,
+ verbatimcontinued=\null
+ '''
+}
diff --git a/docs/document/generatePDF.sh b/docs/document/generatePDF.sh
new file mode 100644
index 0000000..95cd1b7
--- /dev/null
+++ b/docs/document/generatePDF.sh
@@ -0,0 +1,74 @@
+targetDir="content"
+localDir="source"
+mkdir $localDir
+# 默认的语言
+lang="$1"
+if [[ "$lang" == "en" ]] ;then
+ sed -i "s/language = 'zh_CN'/language = 'en_US'/" conf.py
+ echo "printing English version PDF"
+else
+ sed -i "s/language = 'en_US'/language = 'zh_CN'/" conf.py
+ echo "printing Chinese version PDF"
+fi
+
+cp conf.py ${localDir}/
+# 复制所有源文件的内容
+cp -r ${targetDir}/* ${localDir}/
+cd $localDir
+# faq去除编号
+sed -i 's/##[ ][0-9]*./##/g' faq/*
+
+# 建立主目录的index.rst
+echo -e ".. toctree::\n :maxdepth: 1\n :titlesonly:\n" >> index.rst
+
+# 遍历所有的md
+for f in `find . -type f -name "*${lang}.md"`; do
+ title=`grep -oP '^title = "\K[^"]*' $f` # 文件的标题
+ weight=`grep -oP '^weight = \K.*' $f` # 文件的权重(代表文件排版的顺序)
+ sed -i -n '/+++/,/+++/!p' $f # 删除front matter
+ fileName=${f##*/} # 文件名
+ path=${f%/*} # 文件路径
+ lastpath=${path%/*} # 上一级路径
+ foldername=${path##*/} # 当前文件夹名
+ # 如果是index文件则
+ if [[ "${fileName}" == "_index.${lang}.md" ]]
+ then
+ # 将文件的权重写到上一级别的filelist文件中
+ echo -e "${weight}\t${foldername}/index" >> "${lastpath}/filelist.txt"
+ # 当前目录下新建一个index.rst
+ echo "============================" >> "${path}/index.rst"
+ echo $title >> "${path}/index.rst"
+ echo "============================" >> "${path}/index.rst"
+ echo -e ".. toctree::\n :maxdepth: 1\n :titlesonly:\n\n _index.${lang}.md" >> "${path}/index.rst"
+ else
+ # 不是的话添加标题行
+ sed -i "1i # ${title}" $f
+ # 将序号和文件名保存到filelist文件
+ echo -e "${weight}\t${fileName}" >> "${path}/filelist.txt"
+ fi
+done
+
+
+# 所有的filelist进行排序后输出到index.rst中
+for f in `find . -type f -name "*list.txt"`; do
+ path=${f%/*}
+ sort -nk 1 $f | awk '{print $2}' | sed 's/^/ /g' >> "${path}/index.rst"
+ rm $f
+done
+
+# 转换成rst
+for f in `find . -type f -name "*${lang}.md"`; do
+ sed -i -n '/+++/,/+++/!p' $f
+ # 删除所有的图标行因为不能排版
+ sed -i /http.*svg/d $f
+ sed -i /http.*codacy/d $f
+ pandoc $f -o "${f}.rst"
+ rm $f
+done
+
+cd ..
+make latexpdf
+cp _build/latex/*.pdf static/pdf/shadingsphere_docs_${lang}.pdf
+echo "shadingsphere_docs_${lang}.pdf"
+make clean
+rm -rf {_build,source}
\ No newline at end of file
diff --git a/docs/document/requirements.txt b/docs/document/requirements.txt
new file mode 100644
index 0000000..1b3a6e8
--- /dev/null
+++ b/docs/document/requirements.txt
@@ -0,0 +1 @@
+sphinx
\ No newline at end of file
diff --git a/docs/document/static/pdf/shadingsphere_docs_cn.pdf b/docs/document/static/pdf/shadingsphere_docs_cn.pdf
new file mode 100644
index 0000000..5639eed
Binary files /dev/null and b/docs/document/static/pdf/shadingsphere_docs_cn.pdf differ
diff --git a/docs/document/static/pdf/shadingsphere_docs_en.pdf b/docs/document/static/pdf/shadingsphere_docs_en.pdf
new file mode 100644
index 0000000..4be4177
Binary files /dev/null and b/docs/document/static/pdf/shadingsphere_docs_en.pdf differ
diff --git a/docs/document/themes/hugo-theme-learn/layouts/partials/menu.html b/docs/document/themes/hugo-theme-learn/layouts/partials/menu.html
index 2eb7745..e8cd7f2 100644
--- a/docs/document/themes/hugo-theme-learn/layouts/partials/menu.html
+++ b/docs/document/themes/hugo-theme-learn/layouts/partials/menu.html
@@ -86,10 +86,15 @@
{{ end }}
<!-- download button -->
- <!-- <hr /> -->
- <!-- <a class="padding" href=""> no link yet -->
- <!-- <i class="fa fa-fw fa-file-pdf-o" ></i> Download PDF 👈 is a placeholder -->
- <!-- </a> -->
+ <hr />
+ {{ if eq .Lang "en"}}
+ <a class="padding" href="{{"pdf/shadingsphere_docs_en.pdf" | relURL}}">
+ <i class="fa fa-fw fa-file-pdf-o" ></i> Download PDF <!-- is a placeholder -->
+ {{ else }}
+ <a class="padding" href="{{"pdf/shadingsphere_docs_cn.pdf" | relURL}}">
+ <i class="fa fa-fw fa-file-pdf-o" ></i> 下载PDF文档 <!-- is a placeholder -->
+ {{end}}
+ </a>
<section id="footer">
{{ partial "menu-footer.html" . }}