Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrg committed Nov 17, 2024
1 parent 124bb96 commit 70c2da7
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
arch:
- x86
- x64
- x64_arm
#- x64_arm
- x64_arm64
toolset:
# Note: the 14.0 toolset doesn't really work (just results in 14.4)
Expand Down
16 changes: 14 additions & 2 deletions doc/mkdocs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,27 @@ k95.exe -Y -# 127 -C "save keymap %manual_dist_dir%default.ksc,exit" > NUL:

REM Copy manual to the output directory updating version numbers, etc, as we go
REM Parameters are: source-directory destination-directory, git-file-dates dry-run dev-mode web-mode use-https
k95.exe %docs_root%\mkdocs.ksc -Y -d -# 127 = %docs_root%\manual %OUT_DIR% %GIT_DATES% %DRY_RUN% %DEV_MODE% %WEB_MODE% %HTTPS_MODE%
k95.exe %docs_root%\mkdocs.ksc -Y -d -# 127 = %docs_root%\manual %OUT_DIR% %GIT_DATES% %DRY_RUN% %DEV_MODE% %WEB_MODE% %HTTPS_MODE% || goto :failed

REM And update modified dates for anything that hasn't changed since the manual
REM was added to git
if "%DRY_RUN%" == "true" goto :skipfd
k95.exe -Y -H -# 127 -C ".manual_dir := %manual_dist_dir%,.modtime_file := %mtime_file%,rexx call setdates,exit"
k95.exe -Y -H -# 127 -C ".manual_dir := %manual_dist_dir%,.modtime_file := %mtime_file%,rexx call setdates,exit" || goto :failed
:skipfd

echo manual done.
goto :finished

:failed
echo K95 Manual build failed with exit status: %errorlevel%
popd

set REGINA_MACROS=%REGINA_MACROS_OLD%
set REGINA_MACROS_OLD=

exit /B 1

:finished
popd

set REGINA_MACROS=%REGINA_MACROS_OLD%
Expand Down
132 changes: 67 additions & 65 deletions doc/mkdocs.ksc
Original file line number Diff line number Diff line change
Expand Up @@ -197,29 +197,6 @@ define date_to_touch_date {
}
}

; ============================================================================
; Function to update tags in a single file

def process_file {
local file_in file_out gitdate git_date
define \%9

.file_in := \Freplace(\%1,/,\\)
.file_out := \Freplace(\%2,/,\\)
.gitdate := \%3

; ============================================================================
; Get file modified date from git if requested
if = \m(gitdate) 1 {
.git_date := \Fcommand(git log -1 --pretty="format:%ci" \m(file_in) 2> nul)
}

; Update the file. This is done in REXX as its easier (regular expressions)
; and faster.
rexx call mkdocs
}


; ============================================================================
; Process files

Expand All @@ -232,9 +209,13 @@ if neq "\Fsubstring(\m(dest),\flength(\m(dest)),1)" "/" {
.dest := \m(dest)/
}

array declare f
array declare f o

; HTML files that need transforming
dir /array:f /files \m(src)/*.html

dir /array:f /files \m(src)
; Other files that just need copying and maybe touching
dir /array:o /files \m(src)/{*.css,*.gif,*.jpg}

if = \m(web_mode) 0 {
; If not in web-mode, build a list of .html files that will need to be
Expand All @@ -254,49 +235,70 @@ if = \m(web_mode) 0 {

mkdir \m(dest)

echo Processing \fdim(&f) files...
echo Processing \fdim(&f) HTML files...

.\%x = 1
while <= \%x \fdim(&f) {
.idx := \Fsearch(*.{htm,html},\&f[\%x])
for \%x 1 \fdim(&f) 1 {
echo Loop Top iteration \%x of \fdim(&f)

.src_file := \&f[\%x]
.dst_file := \m(dest)\Fbasename(\&f[\%x])
.src_date := \Fdate(\m(src_file))
.file_in := \&f[\%x]
.file_out := \m(dest)\Fbasename(\&f[\%x])

; Its a .html file - it may need its contents updated.
echo \%x. UPDATE \m(file_in) ---> \m(file_out)

if \m(dry_run) {
echo process_file \m(file_in) \m(file_out) \m(touch_files)
} else {

echo Input \m(file_in)
echo Output \m(file_out)

; Update the file. This is done in REXX as its easier
; (regular expressions) and faster.
echo Hand over to REXX
rexx call mkdocs
echo back from REXX
}
echo File processed

}

echo Processing \fdim(&o) Other files...

for \%x 1 \fdim(&o) 1 {
echo Loop Top iteration \%x of \fdim(&o)

.file_in := \&o[\%x]
echo file_in \m(file_in)
.file_out := \m(dest)\Fbasename(\&o[\%x])
echo file_out \m(file_out)
.src_date := \Fdate(\m(file_in))
echo src_date \m(src_date)


echo \%x. COPY \m(file_in) ---> \m(file_out)

if \m(dry_run) {
echo copy /overwrite:always \m(file_in) \m(file_out)
} else {
copy /overwrite:always \m(file_in) \m(file_out)
if fail exit 1
}

if = \m(touch_files) 1 {
; Try with git first, in RFC2822 style: Mon, 19 Aug 2024 19:41:25 +1200
.touch_date := \Fcommand(git log -1 --pretty="format:%cd" --date=format:%Y:%m:%d:%H:%M:%S \m(file_in) 2> nul)

; Convert to the format required by Touch
if = \flength(\m(touch_date)) 0 date_to_touch_date {\m(src_date)} 0

if \m(dry_run) {
echo touch /modtime:\m(touch_date) \m(file_out)
} else {
touch /modtime:\m(touch_date) \m(file_out)
}
}

if = \m(idx) 1 {
echo \%x. UPDATE \m(src_file) ---> \m(dst_file)
if \m(dry_run) {
echo process_file \m(src_file) \m(dst_file) \m(touch_files)
} else {
process_file \m(src_file) \m(dst_file) \m(touch_files)
}
}
else {
echo \%x. COPY \m(src_file) ---> \m(dst_file)

if \m(dry_run) {
echo copy /overwrite:always \m(src_file) \m(dst_file)
} else {
copy /overwrite:always \m(src_file) \m(dst_file)
}

if = \m(touch_files) 1 {
; Try with git first, in RFC2822 style: Mon, 19 Aug 2024 19:41:25 +1200
.touch_date := \Fcommand(git log -1 --pretty="format:%cd" --date=format:%Y:%m:%d:%H:%M:%S \m(src_file) 2> nul)

; Convert to the format required by Touch
if = \flength(\m(touch_date)) 0 date_to_touch_date {\m(src_date)} 0
;else date_to_touch_date {\m(gitdate)} 1

if \m(dry_run) {
echo touch /modtime:\m(touch_date) \m(dst_file)
} else {
touch /modtime:\m(touch_date) \m(dst_file)
}
}
}
increment \%x
}

; TODO: Only do this if the default keymap actually exists
Expand Down
29 changes: 23 additions & 6 deletions doc/mkdocs.rex
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,36 @@ end
*/
input_file = CKermit("return \m(file_in)")
output_file = CKermit("return \m(file_out)")
git_date = CKermit("return \m(git_date)")
dev_mode = CKermit("return \m(dev_mode)")

input_file = changestr("/",input_file,"\")
output_file = changestr("/",output_file,"\")

/* 1 = get file modified times from git, 0 = don't do that */
touch_files = CKermit("return \m(touch_files)")

/* 1 = use https://kermitproject.org, 0 = use http://kermitproject.org */
use_https = CKermit("return \m(use_https)")

/* 1 = generate .html files, 0 = generate .htm files and fix up links */
use_html = CKermit("return \m(web_mode)")


/* This is a list of all html files that we'll replacing references to within
* files */
html_files. = ''

/* This is the date from git, if we're asked to do that */
git_date = ''

if touch_files = 1 then do
/* The usual REXX commands for running other programs or commands don't work
* here as any system commands are actually handed off to Kermit 95 for
* execution as it is in effect our shell. So we've got to ask K95 to run
* git */
git_date = CKermit('return \Fcommand(git log -1 --pretty="format:%ci" \m(file_in) 2> nul)')
end

if use_html = 0 then do
/* If we're renaming html -> htm, then prepare the list of all html
* files! */
Expand All @@ -81,11 +98,11 @@ if use_html = 0 then do
output_file = changestr(".html",output_file,".htm")
end

/*
/**/
say "input_file =" input_file
say "output_file =" output_file
say "git date =" git_date
*/


/* REXX doesn't allow returning stems, get_version_tags will create the tags
* stem as a global, and populate it with information about the Kermit version
Expand Down Expand Up @@ -187,7 +204,7 @@ do while lines(input_file) = 1
/* For debugging
say fields.0 'fields'
do i = 1 to fields.0
say i '»'fields.i'«'
say i ''fields.i''
end*/


Expand All @@ -214,7 +231,7 @@ do while lines(input_file) = 1
/* For debugging
say fields.0 'fields'
do i = 1 to fields.0
say i '»'fields.i'«'
say i ''fields.i''
end
*/

Expand Down Expand Up @@ -272,7 +289,7 @@ get_version_tags: procedure expose tags.
/* For debugging: output each of the things found in the herald
say fields.0 'fields'
do i = 1 to fields.0
say i '»'fields.i'«'
say i ''fields.i''
end*/

tags.ver_num = fields.1 /* $ver$ */
Expand Down

0 comments on commit 70c2da7

Please sign in to comment.