Skip to content

Commit 00e0acf

Browse files
committed
Upload doc to Pages
1 parent 23b8677 commit 00e0acf

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

.github/workflows/kafka_api_gen_doc.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ jobs:
1111
runs-on: ubuntu-20.04
1212
env:
1313
BUILD_SUB_DIR: build/sub-build
14+
1415
steps:
15-
- uses: actions/checkout@v2
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
1619
- name: Install Dependencies
1720
run: |
1821
mkdir -p $BUILD_SUB_DIR
@@ -34,16 +37,39 @@ jobs:
3437
cd $BUILD_SUB_DIR
3538
make VERBOSE=1
3639
37-
- name: Copy
40+
- name: Collect
3841
run: |
39-
mkdir doc-gen
40-
cp $BUILD_SUB_DIR/doc/README.html doc-gen
41-
cp -r $BUILD_SUB_DIR/doc/markdown doc-gen
42-
cp -r $BUILD_SUB_DIR/doc/doxygen doc-gen
42+
mkdir document
43+
cp $BUILD_SUB_DIR/doc/index.html document
44+
cp -r $BUILD_SUB_DIR/doc/markdown document
45+
cp -r $BUILD_SUB_DIR/doc/doxygen document
4346
44-
- name: Upload
47+
- name: Upload Artifact
4548
uses: actions/upload-artifact@v2
4649
with:
4750
name: document
48-
path: doc-gen
51+
path: document
52+
53+
54+
kafka-api-deploy-doc:
55+
needs: [kafka-api-build-doc]
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/[email protected]
60+
with:
61+
persist-credentials: false
62+
63+
- name: Download Artifacts
64+
uses: actions/download-artifact@v1
65+
with:
66+
name: document
67+
68+
#- name: Deploy to Pages
69+
# uses: JamesIves/[email protected]
70+
# with:
71+
# #ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
72+
# branch: gh-pages
73+
# folder: "document"
74+
# clean: true
4975

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,19 @@ To make the life easier, we worked out the `Modern C++ based Kafka API`, -- a he
9292

9393
## Install
9494

95-
* The APIs is headers only
95+
* The APIs is headers only
9696

97-
* Just need to include the `include/kafka` directory in your project
97+
* Just need to include the `include/kafka` directory in your project
9898

99-
* The compiler should support
99+
* The compiler should support
100100

101-
* Option 1: C++17
101+
* Option 1: C++17
102102

103-
* Option 2: C++14, together with `boost` headers (would depend on `boost::optional` in the case)
103+
* Option 2: C++14 (with pre-requirements)
104+
105+
* Need `boost` headers (for `boost::optional`)
106+
107+
* GCC only (with optimization, e.g. -O2)
104108

105109
## Start-up
106110

scripts/markdown2html.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import argparse
66
import time
77
import re
8+
from string import Template
89

910
import markdown
1011

@@ -14,22 +15,27 @@
1415
<head>
1516
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1617
<meta http-equiv="X-UA-Compatible" content="IE=edge">
17-
<title>{title}</title>
18-
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/slate/bootstrap.min.css" rel="stylesheet" integrity="sha384-G9YbB4o4U6WS4wCthMOpAeweY4gQJyyx0P3nZbEBHyz+AtNoeasfRChmek1C2iqV" crossorigin="anonymous">
18+
<title>$title</title>
19+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
20+
<style>
21+
pre { background: #f5f5f5; border: 1px solid #ddd; border-radius: 4px; padding: 0.6em 1em; }
22+
h1,h2 { margin-top: 1em; }
23+
div.navbar { padding: 8px 0; }
24+
div.toc { float: right; }
25+
</style>
1926
</head>
2027
<body>
2128
<div class="container">
22-
{html_content}
29+
$html_content
2330
<hr/>
2431
<footer class="text-center text-muted">
25-
Generated: {date}
32+
Generated: $date
2633
</footer>
2734
<hr/>
2835
</div>
2936
</body>
3037
</html>'''
3138

32-
3339
extensions = ['toc', 'codehilite', 'meta', 'fenced_code', 'tables']
3440
extension_configs = {
3541
'toc' : [('anchorlink', True)],
@@ -51,18 +57,18 @@ def convert(infile, outdir):
5157
else:
5258
md_content_lines.append(line)
5359
md_content = '\n'.join(md_content_lines)
54-
60+
5561
title_found = re.compile("# *(.+)").findall(md_content)
5662
title = '' if not title_found else title_found[0]
57-
63+
5864
html_content = md.convert(md_content)
59-
60-
html_doc = html_template.format(date=time.strftime("%Y. %m. %d"), title=title, html_content=html_content)
65+
66+
html_doc = Template(html_template).substitute(date=time.strftime("%Y. %m. %d"), title=title, html_content=html_content)
6167

6268
if not os.path.exists(outdir):
6369
os.makedirs(outdir)
6470

65-
outfile = os.path.join(outdir, os.path.splitext(os.path.basename(infile))[0] + '.html')
71+
outfile = os.path.join(outdir, 'index.html' if is_root_entry else (os.path.splitext(os.path.basename(infile))[0] + '.html'))
6672
with open(outfile, 'w') as html_file:
6773
html_file.write(html_doc)
6874

@@ -72,9 +78,10 @@ def main():
7278
parser.add_argument("-i", "--in-files", nargs='+', help='<Required> Markdown files to convert', required=True)
7379
parser.add_argument("-o", "--out-dir", help='<Required> The directory to output converted html files', required=True)
7480
args = parser.parse_args()
75-
81+
7682
for in_file in args.in_files:
7783
convert(in_file, args.out_dir)
7884

7985
if __name__ == "__main__":
80-
main()
86+
main()
87+

0 commit comments

Comments
 (0)