📄 uicdocumentdoc.pas
字号:
{Returns the text (formatted) in the format of the documentation. Any special
characters are encoded so the text will appear as is.
~param Text the text to "quote", to return as is
~result the quoted text }
function TICDocumentDoc.HandleRawText(const Text: String): String;
begin
Result := Text; //by default nothing to quote
end;
{Adds the name of the identifier to the node.
~param IdentifierName the name (and path) of the identifier to add
~param AddTo the node to add the name to }
procedure TICDocumentDoc.AddIdentifierText(const IdentifierName: String;
AddTo: TICNCompound);
begin
AddTo.AppendNode(TICNPascalCode.CreatePascalCode(AddTo.Owner,
icpcIdentifier,
IdentifierName));
end;
{Adds the reserved word to the node.
~param ReservedWord the reserved word(s?) to add
~param AddTo the node to add the reserved word to }
procedure TICDocumentDoc.AddReservedWord(const ReservedWord: String;
AddTo: TICNCompound);
begin
AddTo.AppendNode(TICNPascalCode.CreatePascalCode(AddTo.Owner,
icpcReservedWord,
ReservedWord));
end;
{Adds the string to the node.
~param StringText the string tokens to add
~param AddTo the node to add the string to }
procedure TICDocumentDoc.AddString(const StringText: String;
AddTo: TICNCompound);
begin
AddTo.AppendNode(TICNPascalCode.CreatePascalCode(AddTo.Owner,
icpcString, StringText));
end;
{Writes files of all files and their dependance among each other. XFig, EMF and
SVG files may be written, depending on the options set. }
procedure TICDocumentDoc.WriteFileTreeFiles;
var BaseName :String; //base name of the files
begin
if FGenerateFileTreeFiles then //files should be generated?
begin
BaseName := FDestPath + FFileTreeFileBaseName; //calculate base name
//XFig file should be generated?
if fctffXfig in FGenerateFileClassTreeFormats then
WriteFileXFigure(FFiles, BaseName + '.fig'); //generate it
//EMF file should be generated?
if fctffEWMF in FGenerateFileClassTreeFormats then
WriteFileEMF(FFiles, BaseName + '.emf'); //generate it
//SVG file should be generated?
if fctffSVG in FGenerateFileClassTreeFormats then
//generate it
WriteFileSVG(FFiles, BaseName + '.svg', FFileUsageDiagramCallBack);
end;
end;
{Gets the text of the list of files.
~param AddTo the node to add the list of files to }
procedure TICDocumentDoc.AddFileList(AddTo: TICNCompound);
{Adds a link to the given file.
~param TheFile the file to link to
~result a string containing a link to the file }
procedure AddFileLink(TheFile: TPascalFile; AddTo: TICNCompound);
begin
Assert(Assigned(TheFile));
Assert(not DoNotDocumentIdentifier(nil, TheFile));
AddTo.AppendNode(TICNPascalLink.CreateLink(AddTo.Owner, nil, TheFile));
end;
var Dict :TICNDictionary; //dictionary from programs to units
UnitList :TStringList; //to sort the lists of files
{Adds the list of units in UnitList as a TICNList to the dictionary Dict. }
procedure AddList;
var List :TICNList; //the list of units
i :Integer; //counter through all units
AFile :TPascalFile; //each unit
begin
List := TICNList.CreateListSimple(Dict.Owner); //create the list of units
Dict.AppendNode(List);
for i := 0 to UnitList.Count - 1 do //append each used unit
begin
AFile := TPascalFile(UnitList.Objects[i]); //get it
if not DoNotDocumentIdentifier(nil, AFile) then //unit is documented?
AddFileLink(AFile, List); //add it
end;
end;
{Adds the list of included files. }
procedure AddIncludedFiles;
var Heading :TICNCompound; //the heading for the list
Code :TICNFontStyle; //for formattin "$INCLUDE" as code
List :TICNList; //the list of included files
Path :String; //the common path of all files
CommonPathLen :Integer; //the length of the common path
i :Integer; //counter through included files
begin
//add heading for included files
Heading := TICNCompound.CreateCompound(Dict.Owner);
Dict.AppendNode(Heading);
//with this text:
Heading.AppendText(DocumentationTexts[dtFileListIncludedFilesPre].T);
Code := TICNFontStyle.CreateFontStyle(Heading.Owner, icfsCode);
Code.AppendText('$INCLUDE');
Heading.AppendNode(Code);
Heading.AppendText(DocumentationTexts[dtFileListIncludedFilesPost].T);
//create list for the included files
List := TICNList.CreateListSimple(Dict.Owner);
Dict.AppendNode(List);
Path := FFiles.GetCommonBasePath; //get the common path
if Path <> '' then //common path available?
CommonPathLen := Length(FFiles.GetLongPathName(Path)) //get its length
else
CommonPathLen := 0; //no common path
for i := 0 to FFiles.IncludedFileCount - 1 do //add each included file
begin
Path := FFiles.GetLongPathName(FFiles.Included[i].FilePath); //get its path
if CommonPathLen <> 0 then //has a common path?
Delete(Path, 1, CommonPathLen); //remove common part
List.AppendText(Path); //add name of file
end;
end;
var Count :Integer; //number of files in the list
i, j :Integer; //general counter
FileList :TFileList; //list of independent files
AFile :TPascalFile; //a file
begin
//create dictionary from the programs to their units
Dict := TICNDictionary.CreateDictionary(AddTo.Owner, iciiNone,
iciiNormal, icisParagraph);
AddTo.AppendNode(Dict);
FileList := TFileList.Create; //create list of independent files
try
UnitList := TStringList.Create; //create list to sort lists
try
FileList.AddList(FFiles); //add all files to list so far
UnitList.Sorted := True; //list to sort is sorted
UnitList.Duplicates := dupAccept;
Count := FFiles.Count;
for i := Count - 1 downto 0 do //for each file
begin
AFile := FFiles[i]; //get file
if DoNotDocumentIdentifier(nil, AFile) then //file not documented?
FileList.Remove(AFile, False) //ignore it
else
if AFile.FileType <> sftUnit then //file is a project file?
begin
FileList.Remove(AFile, False); //file not independent
UnitList.Clear; //add all used file to (sorted) list
UnitList.AddStrings(AFile.UsedUnitList[fpInterface]);
UnitList.AddStrings(AFile.UsedUnitList[fpMain]);
//all used files are not independent
for j := UnitList.Count - 1 downto 0 do
FileList.Remove(TPascalFile(UnitList.Objects[j]), False);
AddFileLink(AFile, Dict); //add project file heading
AddList; //and all its units
end;
end;
Count := FileList.Count; //number of independent files
if Count > 0 then //some independent units available?
begin
UnitList.Clear;
for j := Count - 1 downto 0 do //add all files to sorted list
begin
AFile := FileList[j]; //add file to list
UnitList.AddObject(AFile.InternalFileName, AFile);
end;
//add heading for independant units
Dict.AppendText(DocumentationTexts[dtFileListIndependentUnits].T);
AddList; //and the list itself
end;
finally
UnitList.Free; //free list to sort lists
end;
finally
FileList.RemoveAll(False); //don't free parser of list
FileList.Free; //free list of independent files
end;
if FFiles.IncludedFileCount > 0 then //files included?
AddIncludedFiles; //add them
if FGenerateFileTreeFiles and (FFiles.Count <> 0) then
//add links to generated diagrams of files
AddTo.AppendNode(TICNTokenClassList.CreateClassListToken(AddTo.Owner,
iccltFileListFileLinks,
rkRecord));
end;
{Writes the documentation of all files. }
procedure TICDocumentDoc.WriteFilesDocumentation;
var Count :Integer; //number of files
Owner :TICNodeOwner; //owner of the list of files
FileList :TICNCompound; //the list of files
i :Integer; //counter through the files
List :TIdentifierFileList; //to sort files alphabetically
AFile :TPascalFile; //the files
begin
if not Progress.ShouldAbort then
begin
Count := FFiles.Count; //get number of files
Progress.SetWorkText('Writing File Documentation...');
Progress.SetProgressText('');
Progress.SetProcessText('Writing Files of File Interdependance...');
Progress.SetMaximum(Count + 2);
if FFiles.Count <> 0 then //if some data present
WriteFileTreeFiles; //write dependance files
if not Progress.StepProgress then
Progress.SetProcessText('Writing List of Files...');
if not Progress.ShouldAbort then
begin
Owner := TICNodeOwner.Create; //create owner for list of files
try
FileList := TICNCompound.CreateCompound(Owner); //and the node for it
AddFileList(FileList); //get list of files
WriteFileList(FileList); //write list of files
finally
Owner.Free; //free the list of files
end;
Progress.StepProgress;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -