Skip to content

Commit 71b599e

Browse files
committed
make HTML build parallel
1 parent 638da70 commit 71b599e

File tree

5 files changed

+101
-16
lines changed

5 files changed

+101
-16
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Generate new HTML documents
3131
run: |
32-
make html
32+
make -j4 html
3333
3434
- name: Check commit IDs
3535
id: commitid

Makefile

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
11
.PHONY: all html clean
22

3-
JEKYLL_WORKDIR=target/jekyll-work
4-
JEKYLL_OUTDIR=target/_site
5-
6-
html-prepare: vim/runtime/doc vim_faq/doc target/html/doc
7-
rm -f target/html/doc/*.txt
8-
cp vim/runtime/doc/*.txt target/html/doc
9-
cp vim_faq/doc/*.txt target/html/doc
3+
VIM_ALL_TEXT = $(wildcard vim/runtime/doc/*.txt)
4+
SRC_TEXT = $(VIM_ALL_TEXT:vim/runtime/doc/%=target/html/doc/%) \
5+
target/html/doc/tags.txt \
6+
target/html/doc/vim_faq.txt
7+
DST_HTML = $(SRC_TEXT:%.txt=%.html)
108

11-
html: html-prepare
12-
-cd target/html/doc ; vim -eu ../../../tools/buildhtml.vim -c "qall!"
9+
html: $(DST_HTML)
10+
@echo completed to generate HTML files
1311

14-
vim/runtime/doc:
12+
vim:
1513
git clone --depth=1 https://github.com/vim/vim.git
1614
cd vim && git apply ../tools/add-vimfaq-link.diff
1715

18-
vim_faq/doc:
16+
vim/runtime/doc/%.txt: vim
17+
18+
vim_faq:
1919
git clone --depth=1 https://github.com/chrisbra/vim_faq.git
2020

21+
vim_faq/doc/vim_faq.txt: vim_faq
22+
2123
target/html/doc:
2224
mkdir -p $@
2325

26+
target/html/doc/tags target/html/doc/tags.txt: $(SRC_TEXT)
27+
-cd target/html/doc && vim -esu ../../../tools/build_tag.vim -c "qall!"
28+
29+
target/html/doc/%.txt: vim/runtime/doc/%.txt target/html/doc
30+
cp $< $@
31+
32+
target/html/doc/vim_faq.txt: vim_faq/doc/vim_faq.txt target/html/doc
33+
cp $< $@
34+
35+
# referenced by $(DST_HTML)
36+
target/html/doc/%.html: target/html/doc/%.txt target/html/doc/tags
37+
-cd target/html/doc && vim -esu ../../../tools/build_html.vim -c "call VimdocEnConvert() | wqall!" $(<F)
38+
2439
clean:
2540
rm -rf target
2641

2742
distclean:
2843
rm -rf vim vim_faq
2944

45+
JEKYLL_WORKDIR=target/jekyll-work
46+
JEKYLL_OUTDIR=target/_site
47+
3048
jekyll-build-prepare:
3149
mkdir -p $(JEKYLL_WORKDIR)
3250
cp target/html/doc/*.html $(JEKYLL_WORKDIR)

tools/build_html.vim

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
set nocompatible
2+
set nomore
3+
set encoding=utf-8
4+
set fileencodings=utf-8
5+
syntax on
6+
colorscheme delek
7+
let g:html_no_progress = 1
8+
9+
source <sfile>:h/tag_aliases.vim
10+
source <sfile>:h/makehtml.vim
11+
12+
let s:tools_dir = expand('<sfile>:p:h')
13+
let s:proj_dir = expand('<sfile>:p:h:h')
14+
15+
function! s:ToJekyll()
16+
let helpname = expand('%:t:r')
17+
if helpname == 'index'
18+
let helpname = 'help'
19+
endif
20+
" remove header
21+
silent 1,/^<hr>/delete _
22+
" remove footer
23+
silent /^<hr>/,$delete _
24+
" escape jekyll tags
25+
silent %s/{\{2,}\|{%/{{ "\0" }}/ge
26+
" YAML front matter
27+
call append(0, [
28+
\ '---',
29+
\ 'layout: vimdoc',
30+
\ printf("helpname: '%s'", helpname),
31+
\ '---',
32+
\ ])
33+
endfunction
34+
35+
" Convert Vim's dodcument in current bufffer to HTML.
36+
function VimdocEnConvert()
37+
set foldlevel=1000
38+
" for the lastest help syntax
39+
let &runtimepath = s:tools_dir . ',' . &runtimepath
40+
" for ja custom syntax
41+
let &runtimepath .= ',' . s:proj_dir
42+
43+
let dst = expand("%:r") . ".html"
44+
45+
call MakeHtml3("", 1)
46+
47+
silent f! `=dst`
48+
49+
set fileformat=unix
50+
call s:ToJekyll()
51+
endfunction

tools/build_tag.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set nocompatible
2+
set nomore
3+
set encoding=utf-8
4+
set fileencodings=utf-8
5+
6+
try
7+
helptags .
8+
catch
9+
echo v:exception
10+
endtry
11+
12+
source <sfile>:h/makehtml.vim
13+
14+
call MakeTagsFile()

tools/makehtml.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ endfunction
7474

7575
function! MakeHtml2(src, dst, conceal)
7676
silent new `=a:src`
77+
call MakeHtml3(s:GetLang(a:src), a:conceal)
78+
silent wq! `=a:dst`
79+
endfunction
7780

81+
" Generate HTML from the current buffer's contents
82+
function! MakeHtml3(lang, conceal)
7883
" 2html options
7984
let g:html_use_css = 1
8085
let g:html_no_pre = 1
@@ -90,8 +95,7 @@ function! MakeHtml2(src, dst, conceal)
9095
silent! %foldopen!
9196
silent! call tohtml#Convert2HTML(1, line('$'))
9297

93-
let lang = s:GetLang(a:src)
94-
silent %s@<span class="\(helpHyperTextEntry\|helpHyperTextJump\|helpOption\|helpCommand\)">\([^<]*\)</span>@\=s:MakeLink(lang, submatch(1), submatch(2), a:conceal)@ge
98+
silent %s@<span class="\(helpHyperTextEntry\|helpHyperTextJump\|helpOption\|helpCommand\)">\([^<]*\)</span>@\=s:MakeLink(a:lang, submatch(1), submatch(2), a:conceal)@ge
9599
silent %s@^<span class="Ignore">&lt;</span>\ze&nbsp;@\&nbsp;@ge
96100
silent %s@<span class="\(helpStar\|helpBar\|Ignore\)">[^<]*</span>@@ge
97101
call s:TranslateHelpExampleBlock()
@@ -100,8 +104,6 @@ function! MakeHtml2(src, dst, conceal)
100104

101105
call s:Header()
102106
call s:Footer()
103-
104-
silent wq! `=a:dst`
105107
endfunction
106108

107109
" <span>...</span> -> <div>...

0 commit comments

Comments
 (0)