DocMgr: added default output name generation

git-svn-id: trunk@34761 -
This commit is contained in:
dodi 2012-01-16 08:49:14 +00:00
parent 911e1f4389
commit 9882727e66
6 changed files with 322 additions and 59 deletions

1
.gitattributes vendored
View File

@ -3701,6 +3701,7 @@ examples/fontenum/mainunit.lrs svneol=native#text/pascal
examples/fontenum/mainunit.pas svneol=native#text/pascal
examples/fpdocmanager/FPDocManager.lpi svneol=native#text/plain
examples/fpdocmanager/FPDocManager.lpr svneol=native#text/plain
examples/fpdocmanager/FilenameExtension.patch svneol=native#text/pascal
examples/fpdocmanager/README.txt svneol=native#text/plain
examples/fpdocmanager/docs/fconfig.xml svneol=native#text/plain
examples/fpdocmanager/docs/flogview.xml svneol=native#text/plain

View File

@ -0,0 +1,173 @@
Index: dw_ipflin.pas
===================================================================
--- dw_ipflin.pas (revision 20081)
+++ dw_ipflin.pas (working copy)
@@ -89,7 +89,6 @@
procedure EndOverview; override;
procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); override;
procedure WriteOverviewMember(const ALabel,AName,ADescr : String); override;
- class function FileNameExtension: string; override;
procedure DescrBeginURL(const AURL: DOMString); override;
procedure DescrEndURL; override;
// Description node conversion. Overrides for TFPDocWriter.
@@ -141,6 +140,7 @@
// TFPDocWriter class methods
public
constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
+ class function FileNameExtension: string; override;
end;
Index: dw_latex.pp
===================================================================
--- dw_latex.pp (revision 20081)
+++ dw_latex.pp (working copy)
@@ -79,7 +79,6 @@
procedure EndOverview; override;
procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); override;
procedure WriteOverviewMember(const ALabel,AName,ADescr : String); override;
- Class Function FileNameExtension : String; override;
// Description node conversion
procedure DescrBeginBold; override;
procedure DescrEndBold; override;
@@ -131,6 +130,8 @@
// TFPDocWriter class methods
Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
Property ImageDir : String Read FImageDir Write FImageDir;
+ public
+ Class Function FileNameExtension : String; override;
end;
Index: dw_linrtf.pp
===================================================================
--- dw_linrtf.pp (revision 20081)
+++ dw_linrtf.pp (working copy)
@@ -114,7 +114,6 @@
procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); override;
procedure WriteOverviewMember(const ALabel,AName,ADescr : String); override;
procedure EndOverview; override;
- Class Function FileNameExtension : String; override;
// Description node conversion
procedure DescrBeginBold; override;
procedure DescrEndBold; override;
@@ -162,6 +161,8 @@
procedure DescrEndTableCell; override;
// TFPDocWriter class methods
Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
+ public
+ Class Function FileNameExtension : String; override;
end;
Index: dw_lintmpl.pp
===================================================================
--- dw_lintmpl.pp (revision 20081)
+++ dw_lintmpl.pp (working copy)
@@ -91,7 +91,6 @@
procedure EndOverview; override;
procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); override;
procedure WriteOverviewMember(const ALabel,AName,ADescr : String); override;
- Class Function FileNameExtension : String; override;
// Description node conversion. Overrides for TFPDocWriter.
procedure DescrBeginBold; override;
procedure DescrEndBold; override;
@@ -139,6 +138,8 @@
procedure DescrEndTableCell; override;
// TFPDocWriter class methods
Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
+ public
+ Class Function FileNameExtension : String; override;
Class procedure Usage(List: TStrings); override;
end;
Index: dw_man.pp
===================================================================
--- dw_man.pp (revision 20081)
+++ dw_man.pp (working copy)
@@ -97,7 +97,6 @@
procedure WriteCommentLine;
procedure WriteComment(Comment : String);
Procedure WriteExampleFile(FN : String); virtual;
- Class Function FileNameExtension : String;virtual;
procedure WriteExample(ADocNode: TDocNode);
procedure WriteSeeAlso(ADocNode: TDocNode; Comma : Boolean);
Public
@@ -178,6 +177,7 @@
procedure DescrBeginTableCell; override;
procedure DescrEndTableCell; override;
Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
+ Class Function FileNameExtension : String; override;
Class procedure Usage(List: TStrings); override;
end;
Index: dw_template.pp
===================================================================
--- dw_template.pp (revision 20081)
+++ dw_template.pp (working copy)
@@ -161,7 +161,7 @@
// Provide feedback about usage of this backend.
Class procedure Usage(List: TStrings); override;
// For info only. See linear writer for an example.
- Class Function FileNameExtension : String;virtual;
+ Class Function FileNameExtension : String; override;
end;
implementation
Index: dw_txt.pp
===================================================================
--- dw_txt.pp (revision 20081)
+++ dw_txt.pp (working copy)
@@ -82,7 +82,6 @@
procedure EndOverview; override;
procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); override;
procedure WriteOverviewMember(const ALabel,AName,ADescr : String); override;
- Class Function FileNameExtension : String; override;
// Description node conversion
procedure DescrBeginBold; override;
procedure DescrEndBold; override;
@@ -130,6 +129,7 @@
procedure DescrEndTableCell; override;
Public
Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
+ Class Function FileNameExtension : String; override;
Class Procedure Usage(List : TStrings) ; override;
Function InterpretOption(Const Cmd,Arg : String) : Boolean; override;
end;
Index: dwlinear.pp
===================================================================
--- dwlinear.pp (revision 20081)
+++ dwlinear.pp (working copy)
@@ -85,7 +85,6 @@
procedure StartUnitOverview(AModuleName,AModuleLabel : String);virtual; Abstract;
procedure WriteUnitEntry(UnitRef : TPasType);virtual; Abstract;
procedure EndUnitOverview; virtual; Abstract;
- Class Function FileNameExtension : String;virtual; Abstract;
Property LastURL : DomString Read FLastURL Write FLastURL;
Public
Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
Index: dwriter.pp
===================================================================
--- dwriter.pp (revision 20081)
+++ dwriter.pp (working copy)
@@ -160,6 +160,7 @@
Property ImageExtension : String Read FImgExt Write FImgExt;
// Should return True if option was succesfully interpreted.
Function InterpretOption(Const Cmd,Arg : String) : Boolean; Virtual;
+ Class Function FileNameExtension : String; virtual;
Class Procedure Usage(List : TStrings); virtual;
procedure WriteDoc; virtual; Abstract;
Function WriteDescr(Element: TPasElement) : TDocNode;
@@ -350,6 +351,12 @@
Result:=False;
end;
+class function TFPDocWriter.FileNameExtension: String;
+begin
+//Override in linear writers with the expected extension.
+ Result := ''; //Output must not contain an extension.
+end;
+
Class procedure TFPDocWriter.Usage(List: TStrings);
begin
// Do nothing.

View File

@ -14,6 +14,11 @@ Organization
A dedicated directory contains all package specifications and documentation.
INI files are created for the manager itself and every package.
Release notes 1.1
-----------------
An optional patch has been added for the FPDoc engines, see fMain $DEFINE FileExt.
Please apply it to $FPC/utils/fpdoc/.
Release notes 1.0
-----------------

View File

@ -1,11 +1,11 @@
object Main: TMain
Left = 335
Height = 423
Height = 462
Top = 146
Width = 569
Align = alClient
Caption = 'Main'
ClientHeight = 403
ClientHeight = 442
ClientWidth = 569
Menu = MainMenu1
OnCreate = FormCreate
@ -13,7 +13,7 @@ object Main: TMain
LCLVersion = '0.9.31'
object lbPackages: TComboBox
Left = 0
Height = 403
Height = 442
Top = 0
Width = 94
Align = alLeft
@ -24,7 +24,7 @@ object Main: TMain
end
object Units: TPageControl
Left = 94
Height = 403
Height = 442
Top = 0
Width = 475
ActivePage = ViewUnits
@ -33,11 +33,11 @@ object Main: TMain
TabOrder = 1
object ViewUnits: TTabSheet
Caption = 'Units'
ClientHeight = 375
ClientHeight = 414
ClientWidth = 467
object lbUnits: TListBox
Left = 0
Height = 375
Height = 414
Top = 0
Width = 100
Align = alLeft
@ -47,12 +47,12 @@ object Main: TMain
end
object GroupBox1: TGroupBox
Left = 100
Height = 375
Height = 414
Top = 0
Width = 367
Align = alClient
Caption = 'Actions'
ClientHeight = 357
ClientHeight = 396
ClientWidth = 363
TabOrder = 1
object swAll: TRadioButton
@ -172,20 +172,20 @@ object Main: TMain
end
object ViewFinal: TTabSheet
Caption = 'Document'
ClientHeight = 375
ClientHeight = 414
ClientWidth = 467
object Label1: TLabel
Left = 10
Height = 16
Top = 74
Top = 40
Width = 39
Caption = 'Format'
ParentColor = False
end
object cbFormat: TComboBox
Left = 70
Left = 71
Height = 23
Top = 72
Top = 40
Width = 375
ItemHeight = 15
OnSelect = cbFormatSelect
@ -196,7 +196,7 @@ object Main: TMain
object swDocOpts: TCheckGroup
Left = 10
Height = 136
Top = 106
Top = 144
Width = 220
AutoFill = True
Caption = 'Options'
@ -225,7 +225,7 @@ object Main: TMain
object Label2: TLabel
Left = 10
Height = 16
Top = 250
Top = 288
Width = 50
Caption = 'OSTarget'
ParentColor = False
@ -233,7 +233,7 @@ object Main: TMain
object Label3: TLabel
Left = 10
Height = 16
Top = 278
Top = 316
Width = 58
Caption = 'CPUTarget'
ParentColor = False
@ -241,7 +241,7 @@ object Main: TMain
object Label4: TLabel
Left = 10
Height = 16
Top = 307
Top = 345
Width = 53
Caption = 'Language'
ParentColor = False
@ -249,7 +249,7 @@ object Main: TMain
object Label5: TLabel
Left = 10
Height = 16
Top = 346
Top = 384
Width = 34
Caption = 'MoDir'
ParentColor = False
@ -257,7 +257,7 @@ object Main: TMain
object Label6: TLabel
Left = 246
Height = 16
Top = 106
Top = 144
Width = 91
Caption = 'Backend Options'
ParentColor = False
@ -275,7 +275,7 @@ object Main: TMain
object edOS: TEdit
Left = 82
Height = 23
Top = 250
Top = 288
Width = 148
OnExit = edOSExit
TabOrder = 3
@ -283,7 +283,7 @@ object Main: TMain
object edCPU: TEdit
Left = 82
Height = 23
Top = 278
Top = 316
Width = 148
OnExit = edOSExit
TabOrder = 4
@ -291,7 +291,7 @@ object Main: TMain
object edLang: TEdit
Left = 82
Height = 23
Top = 307
Top = 345
Width = 148
OnExit = edOSExit
TabOrder = 5
@ -299,7 +299,7 @@ object Main: TMain
object edMoDir: TEdit
Left = 82
Height = 23
Top = 339
Top = 377
Width = 364
OnExit = edOSExit
TabOrder = 6
@ -330,32 +330,49 @@ object Main: TMain
OnClick = buNewProfileClick
TabOrder = 8
end
object Label8: TLabel
Left = 10
Height = 16
Top = 40
Width = 39
Caption = 'Output'
ParentColor = False
end
object edOutput: TEdit
Left = 66
Left = 93
Height = 23
Top = 40
Width = 376
Top = 72
Width = 353
TabOrder = 9
end
object edBackend: TMemo
Left = 246
Height = 200
Hint = 'Enter command=value pairs'
Top = 128
Top = 166
Width = 200
OnExit = lbBackendExit
ParentShowHint = False
ShowHint = True
TabOrder = 10
end
object edDefOut: TEdit
Left = 93
Height = 23
Top = 100
Width = 354
TabOrder = 11
end
object swOutput: TRadioButton
Left = 14
Height = 19
Top = 72
Width = 58
Caption = 'Output'
TabOrder = 13
end
object swDefOut: TRadioButton
Left = 14
Height = 19
Top = 100
Width = 58
Caption = 'Default'
Checked = True
TabOrder = 12
TabStop = True
end
end
object ViewXML: TTabSheet
Caption = 'Project'

View File

@ -6,6 +6,8 @@ unit fMain;
Create documentation (final, test)
*)
{.$DEFINE FileExt} //using class function FilenameExtension?
{$mode objfpc}{$H+}
interface
@ -32,14 +34,16 @@ type
edCPU: TEdit;
edLang: TEdit;
edMoDir: TEdit;
edDefOut: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
edBackend: TMemo;
swOutput: TRadioButton;
swDefOut: TRadioButton;
swDocOpts: TCheckGroup;
Label1: TLabel;
swSortNodes: TCheckBox;
@ -104,8 +108,9 @@ type
procedure SaveOptions;
procedure GetOptions;
procedure GetEngines;
procedure GetProfile(const AName: string);
procedure GetProfile;
procedure SelectFormat(AFmt: string);
procedure FormatSelected;
public
CurPkg: TDocPackage;
CurUnit: string;
@ -119,9 +124,12 @@ implementation
uses
fConfig, fLogView, fUpdateView,
{$IFDEF FileExt}
dwlinear,
{$ELSE}
//fix how?
{$ENDIF}
dWriter;
//dw_HTML, //more writers?
//uLpk;
{$R *.lfm}
@ -332,13 +340,13 @@ begin
cbProfile.Items.CommaText := Manager.Profiles;
cbProfile.Caption := Profile;
end;
GetProfile(Profile);
GetProfile;
end;
procedure TMain.GetProfile(const AName: string);
procedure TMain.GetProfile;
begin
//if Profile = AName then exit; //nothing changed?
Manager.Profile := AName;
//Manager.Profile := AName;
//cbFormat.Caption := Manager.Options.Backend; //select from CB?
SelectFormat(Manager.Options.Backend);
swDocOpts.Checked[0] := Manager.Options.StopOnParseError;
@ -356,16 +364,6 @@ begin
Manager.Options.BackendToPairs(edBackend.Lines);
end;
procedure TMain.SelectFormat(AFmt: string);
var
i: integer;
begin
i := cbFormat.Items.IndexOfName(AFmt);
if i < 0 then
i := cbFormat.Items.Count - 1;
cbFormat.ItemIndex := i;
end;
procedure TMain.edLogChange(Sender: TObject);
begin
LogName:=edLog.Text;
@ -393,7 +391,43 @@ end;
procedure TMain.cbFormatSelect(Sender: TObject);
begin
SaveOptions;
//edOutput.Text := ???;
FormatSelected;
end;
procedure TMain.SelectFormat(AFmt: string);
var
i: integer;
begin
i := cbFormat.Items.IndexOfName(AFmt);
if i < 0 then
i := cbFormat.Items.Count - 1;
cbFormat.ItemIndex := i;
FormatSelected;
end;
procedure TMain.FormatSelected;
var
i: integer;
s: string;
wc: TFPDocWriterClass;
begin
edDefOut.Text := '';
if not assigned(Manager.Package) then
exit; //cannot create package name
i := cbFormat.ItemIndex;
if i < 0 then
exit; //no format selected???
s := cbFormat.Items.Names[i];
wc := GetWriterClass(s);
if not assigned(wc) then exit; //should never happen
s := Manager.RootDir + Manager.Package.Name;
{$IFDEF FileExt}
if wc.InheritsFrom(TLinearWriter) then begin
s := s + wc.FileNameExtension;
end;
{$ELSE}
{$ENDIF}
edDefOut.Text := s;
end;
procedure TMain.GetEngines;
@ -402,6 +436,7 @@ begin
dWriter.EnumWriters(cbFormat.Items);
cbProfile.Items.CommaText := Manager.Profiles;
cbProfile.Caption := Manager.Profile; //select???
cbProfileSelect(cbProfile);
end;
procedure TMain.ProjectsChanged(Sender: TObject);
@ -443,6 +478,7 @@ begin
pkg := lbPackages.Items.Objects[i] as TDocPackage;
if pkg = nil then
exit; //not really created?
Manager.Package := pkg;
fn := pkg.ProjectFile; //initialized where?
if fn <> '' then begin
if FileExists(fn) then
@ -535,7 +571,8 @@ end;
procedure TMain.cbProfileSelect(Sender: TObject);
begin
Profile:=cbProfile.Caption;
GetProfile(Profile);
Manager.Profile := Profile;
GetProfile;
end;
procedure TMain.buRefreshClick(Sender: TObject);
@ -564,7 +601,10 @@ end;
procedure TMain.buMakeDocClick(Sender: TObject);
begin
Manager.MakeDoc(Manager.Package, '');
if swDefOut.Checked then
Manager.MakeDoc(Manager.Package, '', edDefOut.Text)
else
Manager.MakeDoc(Manager.Package, '', edOutput.Text);
end;
end.

View File

@ -17,6 +17,28 @@ This version is decoupled from the fpdoc classes, introduces the classes
TFPDocHelper for fpdoc projects
*)
(* Currently registered writers:
TFPDocWriter in 'dwriter.pp'
template: TTemplateWriter(TFPDocWriter) in 'dw_tmpl.pp'
man: TMANWriter(TFPDocWriter) in 'dw_man.pp' --> <pkg>.man /unit.
dxml: TDXMLWriter(TFPDocWriter) in 'dw_dxml.pp'
xml: TXMLWriter(TFPDocWriter) in 'dw_xml.pp'
html: THTMLWriter(TFPDocWriter) in 'dw_html.pp'
htm: THTMWriter(THTMLWriter)
chm: TCHMHTMLWriter(THTMLWriter)
TLinearWriter in 'dwlinear.pp'
template: TTemplateWriter(TLinearWriter) in 'dw_lintmpl.pp'
ipf: TIPFNewWriter(TLinearWriter) in 'dw_ipflin.pas'
latex: TLaTeXWriter(TLinearWriter) in 'dw_latex.pp'
rtf: TRTFWriter(TLinearWriter) in 'dw_linrtf.pp'
txt: TTXTWriter(TLinearWriter) in 'dw_txt.pp'
TLinearWriter based writers create an single output file for a package:
<path>/pkg .<ext>
TFPDocWriter based writers create an file for every module:
<path>/pkg /unit.<ext>
*)
{$mode objfpc}{$H+}
interface
@ -160,7 +182,7 @@ type
procedure ImportProject(APkg: TFPDocPackage; const AFile: string);
function ImportCmd(const AFile: string): boolean;
//actions
function MakeDoc(APkg: TDocPackage; AUnit: string): boolean;
function MakeDoc(APkg: TDocPackage; const AUnit, AOutput: string): boolean;
function TestRun(APkg: TDocPackage; AUnit: string): boolean;
function Update(APkg: TDocPackage; const AUnit: string): boolean;
public //published?
@ -923,14 +945,16 @@ begin
Changed;
end;
function TFPDocManager.MakeDoc(APkg: TDocPackage; AUnit: string): boolean;
function TFPDocManager.MakeDoc(APkg: TDocPackage; const AUnit, AOutput: string): boolean;
begin
Result := assigned(APkg) and BeginTest(APkg.ProjectFile);
Result := assigned(APkg)
and BeginTest(APkg.ProjectFile)
and APkg.CreateProject(Helper, ''); //only configure, don't create file
if not Result then
exit;
try
//output specification depends on the choosen format!
Helper.ParseFPDocOption('--output="' + RootDir + APkg.Name + '"');
Helper.ParseFPDocOption('--output=' + AOutput);
//Result :=
Helper.CreateUnitDocumentation(AUnit, False);
finally
@ -950,7 +974,10 @@ end;
function TFPDocManager.Update(APkg: TDocPackage; const AUnit: string): boolean;
begin
BeginTest(APkg.ProjectFile);
Result := assigned(APkg)
and BeginTest(APkg.ProjectFile);
if not Result then
exit;
try
Result := APkg.CreateProject(Helper, ''); //only configure, don't create file
if not Result then