📄 uwinhelpfiles.pas
字号:
UsedTitle := UsedTitle +
'Help generated with JADD - Just Another DelphiDoc';
end;
end;
WriteLn(HPFFile, Copy(UsedTitle, 1, 50),
'",(410,200,600,775),27904,,(r12632256),f2');
//also add the two help windows (lists and examples)
WriteLn(HPFFile, HelpWindowNames[hwClassSub],
'="Identifier-Index",(130,225,275,745),4,(r14876671),(r12632256)');
// '="of Class",,4,(r14876671),(r12632256),f4');
WriteLn(HPFFile, HelpWindowNames[hwExample],
'="Example",(420,50,590,650),10500,,(r12632256)');
// '="Example",,10500,,(r12632256)');
WriteLn(HPFFile);
//add a few extra buttons to the main window
WriteLn(HPFFile, '[CONFIG]');
Write(HPFFile, 'CreateButton(btn_content, "',
DocumentationTexts[dtWinHelpButtonOverview].T,
'", JumpId(');
if CompareText(ChangeFileExt(CNTFileName, HelpFileExtension),
HLPFileName) <> 0 then
Write(HPFFile, ChangeFileExt(CNTFileName, HelpFileExtension), ', ');
WriteLn(HPFFile, 'Index))');
WriteLn(HPFFile, 'BrowseButtons()');
WriteLn(HPFFile, 'CreateButton(btn_history, "',
DocumentationTexts[dtWinHelpButtonHistory].T,
'", History())');
WriteLn(HPFFile, 'CreateButton(btn_options, "',
DocumentationTexts[dtWinHelpButtonOptions].T,
'", Menu())');
WriteLn(HPFFile);
WriteLn(HPFFile, '[MAP]'); //write the topic of the mapping
//write file with the mappings
WriteLn(HPFFile, '#include ', Format(HelpContextMappingFileNameFormat,
[FileNameExtra]));
finally
CloseFile(HPFFile); //close the file
end;
end;
{Appends the mapping of help contexts to topics to the help project file.
~param DestPath directory to create the documentation in
~param FileNameExtra additional part for the names of the different files
~param Contexts the list of contexts to log
~param HLPFileName the help file containing the documentation for these help
contexts
~param FilterWith if not nil, the list mapping the help contexts to help
files, a help context will only be written if it is mapped
to the ~[code HLPFileName] with this list }
procedure WriteHelpContexts(const DestPath, FileNameExtra: String;
Contexts: TStringList;
const HLPFileName: String; FilterWith: TStrings);
var HPFFile :TextFile; //the file to append mapping
i :Integer; //counter through the list of mappings
HelpContext :TObject; //each help context in saved type
ContextIndex :Integer; //index of help context in FilterWith
begin
AssignFile(HPFFile, DestPath + Format(HelpContextMappingFileNameFormat,
[FileNameExtra]));
Rewrite(HPFFile); //append to the help project file
try
// WriteLn(HPFFile);
// WriteLn(HPFFile, '[MAP]'); //write the topic of the mapping
if Assigned(FilterWith) then //should be filtered?
begin
for i := 0 to Contexts.Count - 1 do //for each mapping, write it
begin
HelpContext := Contexts.Objects[i]; //get the help context
ContextIndex := FilterWith.IndexOfObject(HelpContext); //search it
if (ContextIndex <> -1) and //is in the specified help file?
(FilterWith[ContextIndex] = HLPFileName) then
//write the mapping
WriteLn(HPFFile, Contexts[i], '=', THelpContext(HelpContext));
end;
end
else
//for each mapping, just write it
for i := 0 to Contexts.Count - 1 do
WriteLn(HPFFile, Contexts[i], '=', Cardinal(Contexts.Objects[i]));
finally
CloseFile(HPFFile); //close the file
end;
end;
{A few examples on notes/warnings/errors in the log file of the compilation of
the Windows Help file:
HC1003: Note: topic #93 of C:\ .. \_doc\.\DelphiDoc.rtf :
A paragraph marker is formatted as a hidden character.
HC1015: Note: topic #93 of C:\ .. \_doc\.\DelphiDoc.rtf :
A page break is formatted as a hidden character.
HC1016: Note: topic #93 of C:\ .. \_doc\.\DelphiDoc.rtf :
A carriage return is formatted as a hidden character.
HC2002: Note:
The keywords "a" and "A" are identical except for case. Help Workshop has modified one keyword to match the other.
HC3025: Warning: topic #11 of C:\ .. \_doc\.\DelphiDoc.rtf :
Jump to undefined Topic ID: "File_MaXnUnit".
HC3026: Warning: topic #2 of C:\ .. \_doc\.\DelphiDoc.rtf :
The Topic ID "legend.Fields" has already been defined in topic 1 in file C:\ .. \_doc\.\DelphiDoc.rtf.
HC3111: Warning: topic #2 of C:\ .. \_doc\.\DelphiDoc.rtf :
This topic contains keywords but no UsedTitle.
HC4011: Warning:
There are 20 opening braces without intervening closing braces.
HC5006: Error: topic #93 of C:\ .. \_doc\.\DelphiDoc.rtf :
Invalid RTF tokens for a table.
}
{Parses the log of a compilation of the Windows Help file. All non-fatal
messages are filtered, i.e. the "Note HC2002" about keywords with different
case.
~param LogFileName the name of the file containing the log
~param HPJFileName the name of the project file
~param FilteredLog out: the filtered log file
~result whether the log file indicates, there has not been any (big) problems
compiling the Windows Help file }
function ParseHelpCompileLogFile(const LogFileName, HPJFileName: String;
var FilteredLog: String): Boolean;
var F :TextFile; //the log file
{Reads the header of the log file.
~result whether the header is valid }
function ParseHeader: Boolean;
var Line :String; //each line of the header
begin
Result := False; //not proven correct so far
ReadLn(F, Line); //read first line
if Line = 'Microsoft (R) Help Compiler' then //is the identification?
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line); //read the next line
if Copy(Line, 1, 6) = 'HCRTF ' then //is version? HCRTF 4.03.0002
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
//is the copyright?
//Copyright (c) Microsoft Corp 1990 - 1995. All rights reserved.
if Copy(Line, 1, 9) = 'Copyright' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
if Line = HPJFileName then //name of project file?
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
Result := True; //seems to be correct
end;
end;
end;
end;
end;
{Reads any note/warning or error message in the log file.
~param NextLine out: the following line, i.e. the first of the summary
~result whether not fatal errors occured }
function ParseMessages(var NextLine: String): Boolean;
var Line :String; //each line of a message
Ignored :Boolean; //whether the message can be ignored
begin
Result := True;
NextLine := '';
ReadLn(F, Line); //read a line
while not Eof(F) and (Copy(Line, 1, 6) = ' HC') do
begin
//HC2002 means identical keywords in different case, can be ignored
Ignored := Copy(Line, 7, 4) = '2002';
Result := Result and Ignored and not Eof(F);
if not Ignored then
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
Result := Result and (Copy(Line, 1, 1) = #9);
if not Ignored then //can not be ignored?
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line); //read the next line
end;
NextLine := Line; //return the following line
end;
{Reads the summary of the log file.
~param FirstLine the first line of the summary
~result whether the summary is valid }
function ParseSummary(const FirstLine: String): Boolean;
var Line :String; //each line of the summary
begin
Line := FirstLine;
Result := False; //not proven correct so far
//read number of topic, f.i.: 6,097<tab>Topics
if Copy(Line, Length(Line) - 6, 7) = #9'Topics' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
//read number of jumps (links), f.i.: 69,909<tab>Jumps
if Copy(Line, Length(Line) - 5, 6) = #9'Jumps' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
//read number of keywords, f.i.: 10,859<tab>Keywords
if Copy(Line, Length(Line) - 8, 9) = #9'Keywords' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
//read number of bitmaps, f.i.: 12<tab>Bitmaps
if (Copy(Line, Length(Line) - 7, 8) = #9'Bitmaps') or
(Copy(Line, Length(Line) - 6, 7) = #9'Bitmap') then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
if Line = '' then //separating empty line
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
if Line = '' then //second separating empty line
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
Result := True;
end;
end;
end;
end;
end;
end;
end;
{Reads the final summary of the log file.
~result whether the summary is valid }
function ParseFinalSummary: Boolean;
var Line :String; //each line of the summary
begin
Result := False; //not proven correct so far
ReadLn(F, Line);
//read result, f.i.: Created C:\ .. \_doc\DelphiDoc.hlp, 2,674,707 bytes
if Copy(Line, 1, 8) = 'Created ' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
//read size of bitmaps, f.i.: Bitmaps: 852 bytes
if Copy(Line, 1, 9) = 'Bitmaps: ' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to filtered log
ReadLn(F, Line);
end;
//read compression, f.i.:
//Hall+Zeck compression decreased help file by 2,896,641 bytes.
if Copy(Line, 1, 21) = 'Hall+Zeck compression' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log and
ReadLn(F, Line); //read next line
end;
//read compile time, f.i.: Compile time: 0 minutes, 8 seconds
if Copy(Line, 1, 14) = 'Compile time: ' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
//read notes and warnings, f.i.: 4 notes, 0 warnings
if Copy(Line, Length(Line) - 8, 9) = ' warnings' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
ReadLn(F, Line);
if Line = '' then
begin
FilteredLog := FilteredLog + Line + LineDelimiter; //add to log
Result := True;
end;
end;
end;
end;
end;
var Line :String; //a line in the file
begin
AssignFile(F, LogFileName);
Reset(F); //open the log file
try
Result := ParseHeader; //read the header
Result := ParseMessages(Line) and Result; //read notes/warnings/errors
Result := ParseSummary(Line) and Result; //read summary
Result := ParseFinalSummary and Result; //read final summary
//make sure end of file has been reached
if not Eof(F) then
ReadLn(F, Line)
else
Line := '';
Result := Result and Eof(F) and (Line = '');
finally
CloseFile(F); //close the log file
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -