Skip to content

Commit

Permalink
Merge pull request #930 from m-tmatma/feature/generate-sakura-hh
Browse files Browse the repository at this point in the history
sakura.hhp` で `sakura_core\sakura.hh` を参照するのをやめてコメントをカットした sakura.hh を使うようにする (python 版)
  • Loading branch information
m-tmatma authored May 28, 2019
2 parents 99bd8d2 + 9f0e056 commit c0c4a19
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/.vs
/cppcheck-*.xml
/cppcheck-install.log
/help/sakura/sakura.hh
/tests/build
/Win32
/x64
Expand Down
1 change: 1 addition & 0 deletions appveyor.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ APPVEYOR_REPO_TAG_NAME は利用をやめて 代わりに GIT_TAG_NAME を使う
- [appveyor_env.py](appveyor_env.py)
- [build-gnu.bat](build-gnu.bat) : (Platform="MinGW"のみ) Makefileをビルドしてbuild-all.batの処理を終了する
- [build-chm.bat](build-chm.bat) : HTML Help をビルドする
- [remove-comment.py](help/remove-comment.py) : UTF-8 でのコンパイルエラーの回避のために日本語を削除するために [sakura.hh](sakura_core/sakura.hh) から一行コメントを削除する
- hhc.exe (Visual Studio 2017 に同梱)
- [run-cppcheck.bat](run-cppcheck.bat) : cppcheck を実行する
- cppcheck.exe
Expand Down
6 changes: 6 additions & 0 deletions build-chm.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ set HHP_SAKURA=help\sakura\sakura.hhp
set CHM_MACRO=help\macro\macro.chm
set CHM_PLUGIN=help\plugin\plugin.chm
set CHM_SAKURA=help\sakura\sakura.chm
set HH_SCRIPT=%~dp0help\remove-comment.py
set HH_INPUT=sakura_core\sakura.hh
set HH_OUTPUT=help\sakura\sakura.hh

del /F "%HH_OUTPUT%"
python "%HH_SCRIPT%" "%HH_INPUT%" "%HH_OUTPUT%" || (echo error && exit /b 1)

call :BuildChm %HHP_MACRO% %CHM_MACRO% || (echo error && exit /b 1)
call :BuildChm %HHP_PLUGIN% %CHM_PLUGIN% || (echo error && exit /b 1)
Expand Down
33 changes: 33 additions & 0 deletions help/remove-comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
import os
import sys
import re
import codecs

# 引数で指定した文字列から改行コードを取り除く
def clipEndOfLine(line):
return line.rstrip('\r\n')

# 行からコメントを削除する
def clipCommet(line):
return re.sub(r'//.*', r'', line)

# ファイルからコメントを削除する
def removeComment(inFile, outFile):
with codecs.open(inFile, "r", "utf_8_sig") as fin:
with codecs.open(outFile, "w", "utf_8_sig") as fout:
for line in fin:
text = clipEndOfLine(line)
text = clipCommet(text)
fout.write(text + "\r\n")

if __name__ == '__main__':
if len(sys.argv) < 3:
print ("usage: " + os.path.basename(sys.argv[0]) + " <src file> <dst file>")
sys.exit(1)

if not os.path.exists(sys.argv[1]):
print (sys.argv[1] + " doesn't exist")
sys.exit(1)

removeComment(sys.argv[1], sys.argv[2])
2 changes: 1 addition & 1 deletion help/sakura/sakura.hhp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ HLP_UR001=res\HLP_UR001.html
HLP_HISTORY=res\HLP_HISTORY.html

[MAP]
#include ../../sakura_core/sakura.hh
#include sakura.hh

[TEXT POPUPS]
Cshelp.txt
Expand Down

0 comments on commit c0c4a19

Please sign in to comment.