mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 16:56:01 +02:00
fpdocmanager heavily refactored.
git-svn-id: trunk@34675 -
This commit is contained in:
parent
10c51b2e9e
commit
3066c21737
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3711,7 +3711,6 @@ examples/fpdocmanager/fmain.pas svneol=native#text/pascal
|
|||||||
examples/fpdocmanager/fpdocengine.lpk svneol=native#text/plain
|
examples/fpdocmanager/fpdocengine.lpk svneol=native#text/plain
|
||||||
examples/fpdocmanager/fupdateview.lfm svneol=native#text/plain
|
examples/fpdocmanager/fupdateview.lfm svneol=native#text/plain
|
||||||
examples/fpdocmanager/fupdateview.pas svneol=native#text/pascal
|
examples/fpdocmanager/fupdateview.pas svneol=native#text/pascal
|
||||||
examples/fpdocmanager/ucmdline.pas svneol=native#text/pascal
|
|
||||||
examples/fpdocmanager/ulpk.pp svneol=native#text/pascal
|
examples/fpdocmanager/ulpk.pp svneol=native#text/pascal
|
||||||
examples/fpdocmanager/umakeskel.pas svneol=native#text/pascal
|
examples/fpdocmanager/umakeskel.pas svneol=native#text/pascal
|
||||||
examples/fpdocmanager/umanager.pas svneol=native#text/pascal
|
examples/fpdocmanager/umanager.pas svneol=native#text/pascal
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
<Icon Value="0"/>
|
<Icon Value="0"/>
|
||||||
</General>
|
</General>
|
||||||
|
<LazDoc Paths="docs"/>
|
||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N LFM="False"/>
|
<EnableI18N LFM="False"/>
|
||||||
</i18n>
|
</i18n>
|
||||||
@ -42,7 +43,7 @@
|
|||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="10">
|
<Units Count="9">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="FPDocManager.lpr"/>
|
<Filename Value="FPDocManager.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -63,44 +64,39 @@
|
|||||||
<UnitName Value="fConfig"/>
|
<UnitName Value="fConfig"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="ucmdline.pas"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<UnitName Value="uCmdLine"/>
|
|
||||||
</Unit3>
|
|
||||||
<Unit4>
|
|
||||||
<Filename Value="umakeskel.pas"/>
|
<Filename Value="umakeskel.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="umakeskel"/>
|
<UnitName Value="umakeskel"/>
|
||||||
</Unit4>
|
</Unit3>
|
||||||
<Unit5>
|
<Unit4>
|
||||||
<Filename Value="umanager.pas"/>
|
<Filename Value="umanager.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="uManager"/>
|
<UnitName Value="uManager"/>
|
||||||
</Unit5>
|
</Unit4>
|
||||||
<Unit6>
|
<Unit5>
|
||||||
<Filename Value="flogview.pas"/>
|
<Filename Value="flogview.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="LogView"/>
|
<ComponentName Value="LogView"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="fLogView"/>
|
<UnitName Value="fLogView"/>
|
||||||
</Unit6>
|
</Unit5>
|
||||||
<Unit7>
|
<Unit6>
|
||||||
<Filename Value="fupdateview.pas"/>
|
<Filename Value="fupdateview.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="UpdateView"/>
|
<ComponentName Value="UpdateView"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="fUpdateView"/>
|
<UnitName Value="fUpdateView"/>
|
||||||
</Unit7>
|
</Unit6>
|
||||||
<Unit8>
|
<Unit7>
|
||||||
<Filename Value="ulpk.pp"/>
|
<Filename Value="ulpk.pp"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="uLpk"/>
|
<UnitName Value="uLpk"/>
|
||||||
</Unit8>
|
</Unit7>
|
||||||
<Unit9>
|
<Unit8>
|
||||||
<Filename Value="$(FPCDir)\utils\fpdoc\dw_html.pp"/>
|
<Filename Value="$(FPCDir)\utils\fpdoc\dw_html.pp"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="dw_HTML"/>
|
<UnitName Value="dw_HTML"/>
|
||||||
</Unit9>
|
</Unit8>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -7,7 +7,7 @@ uses
|
|||||||
cthreads,
|
cthreads,
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
Interfaces, // this includes the LCL widgetset
|
Interfaces, // this includes the LCL widgetset
|
||||||
Forms, dw_HTML, umakeskel, fMain, fConfig, uCmdLine, uManager, fLogView,
|
Forms, dw_HTML, umakeskel, fMain, fConfig, uManager, fLogView,
|
||||||
fUpdateView, ulpk;
|
fUpdateView, ulpk;
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
@ -9,6 +9,11 @@ A package FPDocEngine is supplied for use in commandline or GUI applications.
|
|||||||
uMakeSkel is a copy of parts of the FPDoc and MakeSkel programs, modified
|
uMakeSkel is a copy of parts of the FPDoc and MakeSkel programs, modified
|
||||||
with workarounds for known problems with these FPC tools.
|
with workarounds for known problems with these FPC tools.
|
||||||
|
|
||||||
|
Organization
|
||||||
|
------------
|
||||||
|
A dedicated directory contains all package specifications and documentation.
|
||||||
|
INI files are created for the manager itself and every package.
|
||||||
|
|
||||||
Release notes 1.0
|
Release notes 1.0
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ object CfgWizard: TCfgWizard
|
|||||||
end
|
end
|
||||||
object SelFPDir: TTabSheet
|
object SelFPDir: TTabSheet
|
||||||
Caption = 'FPC'
|
Caption = 'FPC'
|
||||||
ClientHeight = 195
|
ClientHeight = 213
|
||||||
ClientWidth = 312
|
ClientWidth = 310
|
||||||
OnShow = SelFPDirShow
|
OnShow = SelFPDirShow
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -83,7 +83,7 @@ object CfgWizard: TCfgWizard
|
|||||||
Left = 100
|
Left = 100
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 144
|
Top = 144
|
||||||
Width = 200
|
Width = 198
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
OnChange = edFpcDirChange
|
OnChange = edFpcDirChange
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
@ -102,6 +102,7 @@ object CfgWizard: TCfgWizard
|
|||||||
Caption = 'RTL'
|
Caption = 'RTL'
|
||||||
ClientHeight = 213
|
ClientHeight = 213
|
||||||
ClientWidth = 310
|
ClientWidth = 310
|
||||||
|
OnShow = MkRTLShow
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
Left = 10
|
Left = 10
|
||||||
Height = 136
|
Height = 136
|
||||||
|
@ -48,10 +48,11 @@ type
|
|||||||
procedure edRootChange(Sender: TObject);
|
procedure edRootChange(Sender: TObject);
|
||||||
procedure edRtlBatChange(Sender: TObject);
|
procedure edRtlBatChange(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure MkRTLShow(Sender: TObject);
|
||||||
procedure SelFPDirShow(Sender: TObject);
|
procedure SelFPDirShow(Sender: TObject);
|
||||||
procedure SelRootShow(Sender: TObject);
|
procedure SelRootShow(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
NoRun: boolean;
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
end;
|
end;
|
||||||
@ -62,7 +63,7 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
uManager, uCmdLine;
|
uManager;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
@ -95,6 +96,14 @@ begin
|
|||||||
Steps.ActivePage := SelRoot;
|
Steps.ActivePage := SelRoot;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCfgWizard.MkRTLShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
NoRun:=True; //lock updates!
|
||||||
|
edRtlBat.Text := Manager.Packages.Values['rtl'];
|
||||||
|
edFclBat.Text := Manager.Packages.Values['fcl'];
|
||||||
|
NoRun:=False;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCfgWizard.SelFPDirShow(Sender: TObject);
|
procedure TCfgWizard.SelFPDirShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
edFpcDir.Text := Manager.FpcDocDir;
|
edFpcDir.Text := Manager.FpcDocDir;
|
||||||
@ -120,7 +129,9 @@ begin
|
|||||||
fn := ed.Text;
|
fn := ed.Text;
|
||||||
if fn = '' then
|
if fn = '' then
|
||||||
exit;
|
exit;
|
||||||
uCmdLine.CmdToPrj(fn);
|
//uCmdLine.CmdToPrj(fn);
|
||||||
|
if not NoRun then
|
||||||
|
Manager.ImportCmd(fn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCfgWizard.buFclBatClick(Sender: TObject);
|
procedure TCfgWizard.buFclBatClick(Sender: TObject);
|
||||||
|
@ -129,6 +129,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
//UpdateDocs; //package objects seem to be missing?
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMain.FormResize(Sender: TObject);
|
procedure TMain.FormResize(Sender: TObject);
|
||||||
@ -255,8 +256,10 @@ var
|
|||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
lbPackages.Clear;
|
lbPackages.Clear;
|
||||||
for i := 0 to Manager.Projects.Count - 1 do begin
|
for i := 0 to Manager.Packages.Count - 1 do begin
|
||||||
lbPackages.AddItem(Manager.Projects.Names[i], Manager.Projects.Objects[i]);
|
if (Manager.Packages.ValueFromIndex[i] <> '')
|
||||||
|
and (Manager.Packages.Objects[i] <> nil) then
|
||||||
|
lbPackages.AddItem(Manager.Packages.Names[i], Manager.Packages.Objects[i]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
unit uCmdLine;
|
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses
|
|
||||||
Classes, SysUtils;
|
|
||||||
|
|
||||||
function CmdToPrj(const AFileName: string): boolean;
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
uses
|
|
||||||
uManager, umakeskel;
|
|
||||||
|
|
||||||
(* Create an project file from an FPDoc commandline
|
|
||||||
*)
|
|
||||||
function CmdToPrj(const AFileName: string): boolean;
|
|
||||||
var
|
|
||||||
lst: TStringList;
|
|
||||||
l, w: string;
|
|
||||||
prj: TFPDocMaker;
|
|
||||||
begin
|
|
||||||
(* Need a temporary project, that only includes the given files etc.
|
|
||||||
*)
|
|
||||||
Result := False; //in case of errors
|
|
||||||
lst := TStringList.Create;
|
|
||||||
prj := TFPDocMaker.Create(nil);
|
|
||||||
//prj.OnLog := @prj.LogToStdOut; -->ShowMsg???
|
|
||||||
try
|
|
||||||
lst.LoadFromFile(AFileName);
|
|
||||||
l := lst[0];
|
|
||||||
w := GetNextWord(l);
|
|
||||||
if w <> 'fpdoc' then
|
|
||||||
exit; //expected fpdoc command
|
|
||||||
while l <> '' do begin
|
|
||||||
w := GetNextWord(l);
|
|
||||||
prj.ParseFPDocOption(w);
|
|
||||||
end;
|
|
||||||
w := prj.SelectedPackage.Name;
|
|
||||||
if w = '' then
|
|
||||||
exit; //no project name???
|
|
||||||
l := ChangeFileExt(AFileName, '_prj.xml'); //same directory!!!
|
|
||||||
Result := prj.CreateProject(l, prj.SelectedPackage);
|
|
||||||
//now load the project into the manager
|
|
||||||
if Result then
|
|
||||||
//add package/project to the manager
|
|
||||||
Manager.AddProject(w, l, True); //.Packages.Add(w + '=' + l);
|
|
||||||
finally
|
|
||||||
prj.Free;
|
|
||||||
lst.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
|
||||||
|
|
@ -20,22 +20,22 @@ uses
|
|||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
uManager;
|
uManager;
|
||||||
|
|
||||||
//function ImportLpk(const AFile: string): boolean;
|
|
||||||
function ImportLpk(const AFile: string): TDocPackage;
|
function ImportLpk(const AFile: string): TDocPackage;
|
||||||
|
//function ImportCompiled(const LpkFile: string): boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
//uses
|
//uses
|
||||||
|
|
||||||
type
|
type
|
||||||
eKey = (kvEof, kvName, kvIncl, kvOther, kvFilename, kvDocPaths, kvReq
|
eKey = (kvEof, kvName, kvIncl, kvOther, kvFilename, kvDocPaths, kvReq, kvTitle
|
||||||
);
|
);
|
||||||
const
|
const
|
||||||
aKey: array[eKey] of string = (
|
aKey: array[eKey] of string = (
|
||||||
'', 'Name', 'IncludeFiles', 'OtherUnitFiles',
|
'', 'Name', 'IncludeFiles', 'OtherUnitFiles',
|
||||||
'Filename', 'LazDoc' ,'PackageName'
|
'Filename', 'LazDoc' ,'PackageName', 'Title'
|
||||||
);
|
);
|
||||||
FirstKeys = 'NIOFLP';
|
FirstKeys = 'NIOFLPT';
|
||||||
|
|
||||||
var
|
var
|
||||||
f: TextFile;
|
f: TextFile;
|
||||||
@ -59,6 +59,7 @@ begin
|
|||||||
//parse
|
//parse
|
||||||
ReadLn(f, ln);
|
ReadLn(f, ln);
|
||||||
//todo...
|
//todo...
|
||||||
|
//ImportCommandline (CmdToPrj?)
|
||||||
finally
|
finally
|
||||||
CloseFile(f);
|
CloseFile(f);
|
||||||
end;
|
end;
|
||||||
@ -79,8 +80,10 @@ begin
|
|||||||
if i < 1 then
|
if i < 1 then
|
||||||
continue;
|
continue;
|
||||||
key := eKey(i);
|
key := eKey(i);
|
||||||
if Copy(ln, lt+1, Length(aKey[key])) <> aKey[key] then
|
if CompareText(Copy(ln, lt+1, Length(aKey[key])), aKey[key]) <> 0 then
|
||||||
continue;
|
continue; //diff. case in "FileName", "Filename"
|
||||||
|
if key = kvTitle then
|
||||||
|
key := kvName; //LPR
|
||||||
//check value
|
//check value
|
||||||
eq := Pos('=', ln);
|
eq := Pos('=', ln);
|
||||||
if (eq <= lt) or (ln[eq+1] <> '"') then
|
if (eq <= lt) or (ln[eq+1] <> '"') then
|
||||||
@ -97,6 +100,7 @@ end;
|
|||||||
function ImportLpk(const AFile: string): TDocPackage;
|
function ImportLpk(const AFile: string): TDocPackage;
|
||||||
var
|
var
|
||||||
pkg: TDocPackage;
|
pkg: TDocPackage;
|
||||||
|
dir: string;
|
||||||
begin
|
begin
|
||||||
Result := Nil; // False; //assume fail
|
Result := Nil; // False; //assume fail
|
||||||
AssignFile(f, AFile);
|
AssignFile(f, AFile);
|
||||||
@ -112,7 +116,8 @@ begin
|
|||||||
value := 'lcl';
|
value := 'lcl';
|
||||||
pkg := Manager.AddPackage(value);
|
pkg := Manager.AddPackage(value);
|
||||||
pkg.LazPkg := AFile;
|
pkg.LazPkg := AFile;
|
||||||
//Manager.Package := pkg; //!DocPkg
|
dir := ExtractFilePath(AFile);
|
||||||
|
pkg.ProjectDir := dir; //ChDir on exec
|
||||||
//remaining keys
|
//remaining keys
|
||||||
while GetLine do begin
|
while GetLine do begin
|
||||||
case key of
|
case key of
|
||||||
@ -121,18 +126,14 @@ begin
|
|||||||
kvOther: pkg.UnitPath := value;
|
kvOther: pkg.UnitPath := value;
|
||||||
kvFilename:
|
kvFilename:
|
||||||
begin
|
begin
|
||||||
|
if not FileExists(dir + value) then
|
||||||
|
continue;
|
||||||
ext := ExtractFileExt(value);
|
ext := ExtractFileExt(value);
|
||||||
if (ext = '.pas') or (ext = '.pp') then
|
if (ext = '.pas') or (ext = '.pp') then
|
||||||
pkg.Units.Add(value); //!!! no dupes!?
|
pkg.Units.Add(value); //!!! no dupes!?
|
||||||
end;
|
end;
|
||||||
kvDocPaths: pkg.DescrDir := value;
|
kvDocPaths: pkg.DescrDir := value;
|
||||||
kvReq: pkg.Requires.Add(LowerCase(value));
|
kvReq: pkg.Requires.Add(LowerCase(value));
|
||||||
{
|
|
||||||
begin
|
|
||||||
ext := Manager.RootDir + '/' + value + ',../' + value;
|
|
||||||
pkg.Imports.Add(ext);
|
|
||||||
end;
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result := pkg; // True;
|
Result := pkg; // True;
|
||||||
|
@ -65,10 +65,17 @@ resourcestring
|
|||||||
SCreatingNewNode = 'Creating documentation for new node : %s';
|
SCreatingNewNode = 'Creating documentation for new node : %s';
|
||||||
SNodeNotReferenced = 'Documentation node "%s" no longer used';
|
SNodeNotReferenced = 'Documentation node "%s" no longer used';
|
||||||
SDone = 'Done.';
|
SDone = 'Done.';
|
||||||
|
//from fpdocxmlopts
|
||||||
|
SErrInvalidRootNode = 'Invalid options root node: Got "%s", expected "docproject"';
|
||||||
|
SErrNoPackagesNode = 'No "packages" node found in docproject';
|
||||||
|
|
||||||
type
|
type
|
||||||
TCmdLineAction = (actionHelp, actionConvert);
|
TCmdLineAction = (actionHelp, actionConvert);
|
||||||
|
|
||||||
|
(* EngineOptions plus MakeSkel options.
|
||||||
|
Used in the commandline parsers, passed to the Engine.
|
||||||
|
Project.Options are ignored by TFDocMaker.(?)
|
||||||
|
*)
|
||||||
TCmdOptions = class(TEngineOptions)
|
TCmdOptions = class(TEngineOptions)
|
||||||
public
|
public
|
||||||
WriteDeclaration,
|
WriteDeclaration,
|
||||||
@ -157,7 +164,6 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AddDirToFileList(List: TStrings; const ADirName, AMask: String);
|
procedure AddDirToFileList(List: TStrings; const ADirName, AMask: String);
|
||||||
procedure AddToFileList(List: TStrings; const FileName: String);
|
procedure AddToFileList(List: TStrings; const FileName: String);
|
||||||
function UnitName(AList: TStrings; AIndex: integer): string;
|
|
||||||
function UnitSpec(AUnit: string): string;
|
function UnitSpec(AUnit: string): string;
|
||||||
function ImportName(AIndex: integer): string;
|
function ImportName(AIndex: integer): string;
|
||||||
procedure LogToStdOut(Sender: TObject; const msg: string);
|
procedure LogToStdOut(Sender: TObject; const msg: string);
|
||||||
@ -166,8 +172,10 @@ type
|
|||||||
function ParseFPDocOption(const S: string): TCreatorAction;
|
function ParseFPDocOption(const S: string): TCreatorAction;
|
||||||
function ParseUpdateOption(const S: string): TCreatorAction;
|
function ParseUpdateOption(const S: string): TCreatorAction;
|
||||||
function CheckSkelOptions: string;
|
function CheckSkelOptions: string;
|
||||||
function CreateProject(const AFileName: string; APackage: TFPDocPackage): boolean; virtual;
|
function CleanXML(const FileName: string): boolean;
|
||||||
{$IFDEF v0}
|
{$IFDEF v0}
|
||||||
|
function CreateProject(const AFileName: string; APackage: TFPDocPackage): boolean; virtual;
|
||||||
|
procedure LoadXMLProject(const AFileName: string);
|
||||||
function ParseOption(const S: string): TCreatorAction;
|
function ParseOption(const S: string): TCreatorAction;
|
||||||
function Exec: string;
|
function Exec: string;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -201,81 +209,27 @@ var
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
//Extract next commandline option from a string
|
||||||
Function GetNextWord(Var s : string) : String;
|
Function GetNextWord(Var s : string) : String;
|
||||||
|
|
||||||
|
//Get package name from Imports spec
|
||||||
|
function ExtractImportName(const s: string): string;
|
||||||
|
//Get Unit filename from Inputs or Descriptions
|
||||||
|
function UnitFile(AList: TStrings; AIndex: integer): string;
|
||||||
|
//Get Unit name from Inputs or Descriptions
|
||||||
|
function ExtractUnitName(AList: TStrings; AIndex: integer): string;
|
||||||
|
function ExtractUnitName(s: string): string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
dom,
|
dom,
|
||||||
dWriter, fpdocxmlopts;
|
dWriter;
|
||||||
|
|
||||||
type
|
(* Extract (remove!) next commandline option from a string.
|
||||||
(* special save/load options
|
Handle quoted arguments, but do not unquote.
|
||||||
|
Option may be partially quoted, e.g. -opt="arg with blanks"
|
||||||
*)
|
*)
|
||||||
|
|
||||||
{ TXMLPackageOptions }
|
|
||||||
|
|
||||||
TXMLPackageOptions = class(TXMLFPDocOptions)
|
|
||||||
public
|
|
||||||
Pkg: TFPDocPackage;
|
|
||||||
procedure SaveOptionsToFile(AProject: TFPDocProject; const AFileName: String; APackage: TFPDocPackage);
|
|
||||||
procedure SaveToXML(AProject: TFPDocProject; ADoc: TXMLDocument); override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TNodePair = Class(TObject)
|
|
||||||
Private
|
|
||||||
FEl : TPasElement;
|
|
||||||
FNode : TDocNode;
|
|
||||||
Public
|
|
||||||
Constructor Create(AnElement : TPasElement; ADocNode : TDocNode);
|
|
||||||
Property Element : TPasElement Read FEl;
|
|
||||||
Property DocNode : TDocNode Read FNode;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TXMLPackageOptions }
|
|
||||||
|
|
||||||
procedure TXMLPackageOptions.SaveOptionsToFile(AProject: TFPDocProject;
|
|
||||||
const AFileName: String; APackage: TFPDocPackage);
|
|
||||||
begin
|
|
||||||
Pkg := APackage; //for use in SaveXML
|
|
||||||
inherited SaveOptionsToFile(AProject, AFileName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TXMLPackageOptions.SaveToXML(AProject: TFPDocProject;
|
|
||||||
ADoc: TXMLDocument);
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
E,PE: TDOMElement;
|
|
||||||
begin
|
|
||||||
if false then inherited SaveToXML(AProject, ADoc);
|
|
||||||
E:=ADoc.CreateElement('docproject');
|
|
||||||
ADoc.AppendChild(E);
|
|
||||||
E:=ADoc.CreateElement('options');
|
|
||||||
ADoc.DocumentElement.AppendChild(E);
|
|
||||||
SaveEngineOptions(AProject.Options,ADoc,E);
|
|
||||||
E:=ADoc.CreateElement('packages');
|
|
||||||
ADoc.DocumentElement.AppendChild(E);
|
|
||||||
if assigned(Pkg) then begin
|
|
||||||
PE:=ADoc.CreateElement('package');
|
|
||||||
E.AppendChild(PE);
|
|
||||||
SavePackage(Pkg,ADoc,PE);
|
|
||||||
end else begin
|
|
||||||
for i := 0 to AProject.Packages.Count - 1 do
|
|
||||||
begin
|
|
||||||
PE:=ADoc.CreateElement('package');
|
|
||||||
E.AppendChild(PE);
|
|
||||||
SavePackage(AProject.Packages[i],ADoc,PE);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Constructor TNodePair.Create(AnElement : TPasElement; ADocNode : TDocNode);
|
|
||||||
|
|
||||||
begin
|
|
||||||
Fel:=Anelement;
|
|
||||||
FNode:=ADocNode;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Function GetNextWord(Var s : string) : String;
|
Function GetNextWord(Var s : string) : String;
|
||||||
Const
|
Const
|
||||||
WhiteSpace = [' ',#9,#10,#13];
|
WhiteSpace = [' ',#9,#10,#13];
|
||||||
@ -306,6 +260,69 @@ begin
|
|||||||
Delete(S,1,J);
|
Delete(S,1,J);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ExtractImportName(const s: string): string;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
Result := s;
|
||||||
|
i := Pos(',', Result);
|
||||||
|
if i > 1 then
|
||||||
|
SetLength(Result, i-1);
|
||||||
|
Result := ChangeFileExt(ExtractFileName(Result), '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ExtractUnitName(s: string): string;
|
||||||
|
begin
|
||||||
|
Result := ChangeFileExt(ExtractFileName(s), '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
(* Unit name from Inputs[i] or Descriptions[i]
|
||||||
|
Package name from Imports?
|
||||||
|
*)
|
||||||
|
function ExtractUnitName(AList: TStrings; AIndex: integer): string;
|
||||||
|
begin
|
||||||
|
Result := UnitFile(AList, AIndex);
|
||||||
|
if Result <> '' then
|
||||||
|
Result := ChangeFileExt(ExtractFileName(Result), '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
(* Extract a file reference from Inputs or Descriptions list.
|
||||||
|
Check for existing list and item.
|
||||||
|
*)
|
||||||
|
function UnitFile(AList: TStrings; AIndex: integer): string;
|
||||||
|
var
|
||||||
|
s: string;
|
||||||
|
begin
|
||||||
|
if assigned(AList) and (AIndex < AList.Count) then begin
|
||||||
|
s := AList[AIndex];
|
||||||
|
while s <> '' do begin
|
||||||
|
Result := GetNextWord(s);
|
||||||
|
if (Result <> '') and (Result[1] <> '-') then
|
||||||
|
exit; //found a non-option
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := ''; //should never happen!
|
||||||
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
TNodePair = Class(TObject)
|
||||||
|
Private
|
||||||
|
FEl : TPasElement;
|
||||||
|
FNode : TDocNode;
|
||||||
|
Public
|
||||||
|
Constructor Create(AnElement : TPasElement; ADocNode : TDocNode);
|
||||||
|
Property Element : TPasElement Read FEl;
|
||||||
|
Property DocNode : TDocNode Read FNode;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Constructor TNodePair.Create(AnElement : TPasElement; ADocNode : TDocNode);
|
||||||
|
|
||||||
|
begin
|
||||||
|
Fel:=Anelement;
|
||||||
|
FNode:=ADocNode;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSkelEngine.FindModule(const AName: String): TPasModule;
|
function TSkelEngine.FindModule(const AName: String): TPasModule;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -636,30 +653,13 @@ begin
|
|||||||
Result := FDescrDir;
|
Result := FDescrDir;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(* Unit name from Inputs[i] or Descriptions[i]
|
|
||||||
Package name from Imports?
|
|
||||||
*)
|
|
||||||
function TFPDocMaker.UnitName(AList: TStrings; AIndex: integer): string;
|
|
||||||
var
|
|
||||||
w: string;
|
|
||||||
begin
|
|
||||||
Result := AList[AIndex];
|
|
||||||
while Result <> '' do begin
|
|
||||||
w := GetNextWord(Result);
|
|
||||||
if (w <> '') and (w[1] <> '-') then begin
|
|
||||||
Result := ChangeFileExt(ExtractFileName(w), '');
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TFPDocMaker.UnitSpec(AUnit: string): string;
|
function TFPDocMaker.UnitSpec(AUnit: string): string;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
s, w: string;
|
s, w: string;
|
||||||
begin
|
begin
|
||||||
for i := 0 to SelectedPackage.Inputs.Count - 1 do begin
|
for i := 0 to SelectedPackage.Inputs.Count - 1 do begin
|
||||||
w := UnitName(FPackage.Inputs, i);
|
w := ExtractUnitName(FPackage.Inputs, i);
|
||||||
if CompareText(w, AUnit) = 0 then begin
|
if CompareText(w, AUnit) = 0 then begin
|
||||||
Result := FPackage.Inputs[i];
|
Result := FPackage.Inputs[i];
|
||||||
exit;
|
exit;
|
||||||
@ -669,15 +669,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPDocMaker.ImportName(AIndex: integer): string;
|
function TFPDocMaker.ImportName(AIndex: integer): string;
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
begin
|
begin
|
||||||
Result := SelectedPackage.Imports[AIndex];
|
Result := ExtractImportName(SelectedPackage.Imports[AIndex]);
|
||||||
i := Pos(',', Result);
|
|
||||||
if i > 1 then
|
|
||||||
SetLength(Result, i-1);
|
|
||||||
Result := ExtractFileName(Result);
|
|
||||||
Result := ChangeFileExt(Result, '');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPDocMaker.GetInputDir: string;
|
function TFPDocMaker.GetInputDir: string;
|
||||||
@ -752,12 +745,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF v0}
|
||||||
function TFPDocMaker.CreateProject(const AFileName: string; APackage: TFPDocPackage): boolean;
|
function TFPDocMaker.CreateProject(const AFileName: string; APackage: TFPDocPackage): boolean;
|
||||||
var
|
var
|
||||||
f: TXMLPackageOptions;
|
f: TXMLPackageProject;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
f := TXMLPackageOptions.Create(nil);
|
f := TXMLPackageProject.Create(nil);
|
||||||
try
|
try
|
||||||
f.SaveOptionsToFile(Project, AFileName, APackage);
|
f.SaveOptionsToFile(Project, AFileName, APackage);
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -769,6 +763,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocMaker.LoadXMLProject(const AFileName: string);
|
||||||
|
var
|
||||||
|
f: TXMLPackageProject;
|
||||||
|
begin
|
||||||
|
//LoadProjectFile();
|
||||||
|
f := TXMLPackageProject.Create(self);
|
||||||
|
try
|
||||||
|
f.LoadOptionsFromFile(Project, AFileName);
|
||||||
|
finally
|
||||||
|
f.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure TFPDocMaker.SetCmdAction(AValue: TCreatorAction);
|
procedure TFPDocMaker.SetCmdAction(AValue: TCreatorAction);
|
||||||
begin
|
begin
|
||||||
if FCmdAction=AValue then Exit;
|
if FCmdAction=AValue then Exit;
|
||||||
@ -1057,6 +1066,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(* Return True and (try) kill file if no "<element" found.
|
||||||
|
*)
|
||||||
|
function TFPDocMaker.CleanXML(const FileName: string): boolean;
|
||||||
|
var
|
||||||
|
f: TextFile;
|
||||||
|
s: string;
|
||||||
|
begin
|
||||||
|
AssignFile(f, FileName);
|
||||||
|
Reset(f);
|
||||||
|
try
|
||||||
|
while not EOF(f) do begin
|
||||||
|
ReadLn(f, s);
|
||||||
|
if Pos('<element ', s) > 0 then
|
||||||
|
exit(False); //file not empty
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
CloseFile(f);
|
||||||
|
end;
|
||||||
|
//nothing found, delete the file
|
||||||
|
if DeleteFile(FileName) then
|
||||||
|
DoLog('File ' + FileName + ' has no elements. Deleted.')
|
||||||
|
else
|
||||||
|
DoLog('File ' + FileName + ' has no elements. Delete failed.');
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TFPDocMaker.ParseUpdateOption(const s: String): TCreatorAction;
|
function TFPDocMaker.ParseUpdateOption(const s: String): TCreatorAction;
|
||||||
//procedure ParseOption(const s: String; Options: TEngineOptions);
|
//procedure ParseOption(const s: String; Options: TEngineOptions);
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user