📄 uclmain.pas
字号:
{ JADD - Just Another DelphiDoc: Documentation from Delphi Source Code
Copyright (C) 2003-2008 Gerold Veith
This file is part of JADD - Just Another DelphiDoc.
DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit UCLMain;
{Contains the function ~[link Main] possessing the functionality of the
commandline program of DelphiDoc. }
interface
//Handles the parameters by parsing the pascal data and generating
//documentation.
function Main(SkipFirstParam: Boolean): Boolean;
implementation
uses Windows, Classes, SysUtils, IniFiles,
UCommandParameters,
UParametersToState,
UProgress,
UJADDState,
UPascalConsts, //TPosition
UBaseIdents, //TPascalFile
UTokenParser, //EParseException
UGenerationMessages, //MessageSeriousnesses
UMakeDoc, //GeneratorClasses
UCommentExtraction, //ExtractorClasses
//not directly used here, but units have to be included in the project
//somewhere
UJADDComments,
//not directly used here, but units have to be included in the project
//somewhere
USourceCommentExtraction,
//not directly used here, but units have to be included in the project
//somewhere
UInlineCommand,
//not used, but have to be included somewhere:
UDiagramCreator,UExtractSourceDoc, USaveDataDoc, UUMLXMIExportDoc,
//deprecated generators
UHTMLDoc, UWinHelpDoc, ULaTeXDoc, UPDFDoc, UHTMLHelpDoc,
//"release candidates"
UICWinHelpDoc, UICHTMLDoc, UICHTMLHelpDoc, UICLaTeXDoc, UICPDFDoc,
//not a real generator, just makes localization easier
USaveTranslation,
UDocumentationTexts;
type
{Handles the parameters of the program for this command line version. }
TCLParameterOptions = class(TJADDParameterOptions)
private
//whether documentation should be generated, concluding from the parameters
FNeedAutoGeneration: Boolean;
protected
//Parses the selected files with source code.
function DoParse: Boolean; override;
//Generates the documentation with the current settings.
function DoGenerate: Boolean; override;
//Will be called for each parsed parameter of the program.
function ParamFunc(Parameter: TParameter; SingleChar: Char;
const Value: String; HasValue: Boolean): Boolean;
override;
public
//Generates the documentation at the end, when there was no explicit
//parameter to do it.
procedure CheckAutoGeneration;
end;
//Sets the progress interface to be verbose or not, depending on the current
//options.
procedure SetProgressInterface; forward;
//Parses the pascal data.
function Parse: Boolean; forward;
//Prints the messages that have been generated while parsing.
procedure PrintParsingMessages; forward;
//Prints all unknown identifiers and types.
procedure PrintUnknownIdentifiers; forward;
//Prints all messages generated while generating documentation.
procedure PrintGenerationMessages; forward;
var State :TJADDState = nil; //state of the program
Progress :TCommandLineProgress = nil; //to show the progress
ShowProgress :Boolean = True; //progress shown
Filter :TMessageFilter = nil; //filter on messages
Parameters :TCLParameterOptions = nil; //parsed parameter values
{Parses the selected files with source code.
~result whether the selected files were successfully parsed }
function TCLParameterOptions.DoParse: Boolean;
begin
SetProgressInterface; //set interface to show progress
Result := Parse; //parse the data
if Result then //everything's fine?
State.KeepCurrentData; //keep it, just for fun
//verbose on parsing messages?
if vaParsing in VerboseOutput then
PrintParsingMessages; //print the parsing messages
//verbose on the list of unknown identifiers and files and types
if vaUnknownIdentifiers in VerboseOutput then
PrintUnknownIdentifiers; //print unknown identifiers
end;
{Generates the documentation with the current settings.
~result whether the documentation was successfully generated }
function TCLParameterOptions.DoGenerate: Boolean;
begin
SetProgressInterface; //set interface to show progress
try
//generate documentation in the selected kind
case GenerationKind of
dgkDelphiDoc: Result := State.GenerateDocumentation(False);
dgkUserDoc: Result := State.GenerateDocumentation(True);
dgkGUIHelp: Result := State.GenerateGUIHelp;
else
Assert(False);
Result := False;
end;
finally
if vaGeneration in VerboseOutput then //verbose on generation?
PrintGenerationMessages; //print all messages
end;
if (vaGeneration in VerboseOutput) and //verbose on generation?
(State.Generate.GetGenerateStatusText <> '') then //and status available
WriteLn(State.Generate.GetGenerateStatusText); //print the status
end;
{Will be called for each parsed parameter of the program.
~param Parameter the kind of the parameter
~param SingleChar the single character used for the option, if the long option
has be used it will be #0
~param Value the value of the parameter of the parameter, '' if none
specified
~param HasValue whether a parameter has been specified for the option
~result whether the function should be called for the next parameter or parsing
them should be aborted
~exception EParameterException when the parameter or its value is invalid }
function TCLParameterOptions.ParamFunc(Parameter: TParameter; SingleChar: Char;
const Value: String;
HasValue: Boolean): Boolean;
begin
//handle the parameter
Result := inherited ParamFunc(Parameter, SingleChar, Value, HasValue);
//error in parameter or just generated documentation?
if not Result or (Parameter = pGenerate) then
FNeedAutoGeneration := False //no need to generate (again)
else
//check whether new data has been loaded or options been set, what does only
//make sense, when new documentation should be generated
FNeedAutoGeneration := FNeedAutoGeneration or
(Parameter in
[pSourceProject, pExecutable, pLoadParsedData,
pGenerator,
pDocumentationPath, pDocumentationFileName,
pGenerationOption,
pLocalize, pLoadLocalization, pUseLanguage,
pUserDocumentation, pClearUserDocumentation,
pGUILogFile, pClearGUILogFiles,
pLoadGUIHelpProject]);
end;
{Generates the documentation at the end, when there was no explicit parameter
to do it. }
procedure TCLParameterOptions.CheckAutoGeneration;
begin
if FNeedAutoGeneration then //documentation needs to be generated?
DoGenerate; //do it now
end;
{Sets the progress interface to be verbose or not, depending on the current
options. }
procedure SetProgressInterface;
begin
//showing of the progress changed?
if Parameters.ShowProgress <> ShowProgress then
begin
if Parameters.ShowProgress then //create new object to observe Ctrl-C
Progress := TVerboseCommandLineProgress.Create
else
Progress := TCommandLineProgress.Create;
State.Progress := Progress;
//set the new state
ShowProgress := Parameters.ShowProgress;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -