From fd406b79eafba8aa4f79f28b035097347e6c6c82 Mon Sep 17 00:00:00 2001 From: dodi Date: Wed, 11 Jan 2012 13:48:51 +0000 Subject: [PATCH] DocMgr: added documentation git-svn-id: trunk@34710 - --- .gitattributes | 7 + examples/fpdocmanager/FPDocManager.lpi | 10 +- examples/fpdocmanager/FPDocManager.lpr | 2 +- examples/fpdocmanager/docs/fconfig.xml | 481 +++++++++ examples/fpdocmanager/docs/flogview.xml | 69 ++ examples/fpdocmanager/docs/fmain.xml | 693 +++++++++++++ examples/fpdocmanager/docs/fupdateview.xml | 48 + examples/fpdocmanager/docs/ulpk.xml | 30 + examples/fpdocmanager/docs/umakeskel.xml | 1001 +++++++++++++++++++ examples/fpdocmanager/docs/umanager.xml | 1021 ++++++++++++++++++++ examples/fpdocmanager/fmain.lfm | 22 +- examples/fpdocmanager/fmain.pas | 11 +- examples/fpdocmanager/fpdocengine.lpk | 4 + examples/fpdocmanager/ulpk.pp | 32 +- examples/fpdocmanager/umakeskel.pas | 5 +- examples/fpdocmanager/umanager.pas | 111 ++- 16 files changed, 3469 insertions(+), 78 deletions(-) create mode 100644 examples/fpdocmanager/docs/fconfig.xml create mode 100644 examples/fpdocmanager/docs/flogview.xml create mode 100644 examples/fpdocmanager/docs/fmain.xml create mode 100644 examples/fpdocmanager/docs/fupdateview.xml create mode 100644 examples/fpdocmanager/docs/ulpk.xml create mode 100644 examples/fpdocmanager/docs/umakeskel.xml create mode 100644 examples/fpdocmanager/docs/umanager.xml diff --git a/.gitattributes b/.gitattributes index 8f893ed4c3..e3dba0453e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3702,6 +3702,13 @@ 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/README.txt svneol=native#text/plain +examples/fpdocmanager/docs/fconfig.xml svneol=native#text/plain +examples/fpdocmanager/docs/flogview.xml svneol=native#text/plain +examples/fpdocmanager/docs/fmain.xml svneol=native#text/plain +examples/fpdocmanager/docs/fupdateview.xml svneol=native#text/plain +examples/fpdocmanager/docs/ulpk.xml svneol=native#text/plain +examples/fpdocmanager/docs/umakeskel.xml svneol=native#text/plain +examples/fpdocmanager/docs/umanager.xml svneol=native#text/plain examples/fpdocmanager/fconfig.lfm svneol=native#text/plain examples/fpdocmanager/fconfig.pas svneol=native#text/pascal examples/fpdocmanager/flogview.lfm svneol=native#text/plain diff --git a/examples/fpdocmanager/FPDocManager.lpi b/examples/fpdocmanager/FPDocManager.lpi index b4ec49b0a1..5eee9270ac 100644 --- a/examples/fpdocmanager/FPDocManager.lpi +++ b/examples/fpdocmanager/FPDocManager.lpi @@ -43,7 +43,7 @@ - + @@ -92,11 +92,6 @@ - - - - - @@ -107,7 +102,6 @@ - @@ -121,7 +115,7 @@ - + diff --git a/examples/fpdocmanager/FPDocManager.lpr b/examples/fpdocmanager/FPDocManager.lpr index 07cf45c73f..e64d2be788 100644 --- a/examples/fpdocmanager/FPDocManager.lpr +++ b/examples/fpdocmanager/FPDocManager.lpr @@ -7,7 +7,7 @@ uses cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset - Forms, dw_HTML, umakeskel, fMain, fConfig, uManager, fLogView, + Forms, umakeskel, fMain, fConfig, uManager, fLogView, fUpdateView, ulpk; {$R *.res} diff --git a/examples/fpdocmanager/docs/fconfig.xml b/examples/fpdocmanager/docs/fconfig.xml new file mode 100644 index 0000000000..a384711b38 --- /dev/null +++ b/examples/fpdocmanager/docs/fconfig.xml @@ -0,0 +1,481 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/flogview.xml b/examples/fpdocmanager/docs/flogview.xml new file mode 100644 index 0000000000..8e92202648 --- /dev/null +++ b/examples/fpdocmanager/docs/flogview.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/fmain.xml b/examples/fpdocmanager/docs/fmain.xml new file mode 100644 index 0000000000..586c828cdb --- /dev/null +++ b/examples/fpdocmanager/docs/fmain.xml @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/fupdateview.xml b/examples/fpdocmanager/docs/fupdateview.xml new file mode 100644 index 0000000000..3190e7890a --- /dev/null +++ b/examples/fpdocmanager/docs/fupdateview.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/ulpk.xml b/examples/fpdocmanager/docs/ulpk.xml new file mode 100644 index 0000000000..74df74f3b9 --- /dev/null +++ b/examples/fpdocmanager/docs/ulpk.xml @@ -0,0 +1,30 @@ + + + + + + + + + + Imports an .lpi or .lpk file, creates a documentation project. + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/umakeskel.xml b/examples/fpdocmanager/docs/umakeskel.xml new file mode 100644 index 0000000000..bab5df8fe2 --- /dev/null +++ b/examples/fpdocmanager/docs/umakeskel.xml @@ -0,0 +1,1001 @@ + + + + + + An extract from the FPC MakeSkel program, with some extensions. + + TFPDocMaker extends FPDoc TFPDocCreator, with ability to update the XML files. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [?] + + + + + + Specifies the MakeSkel engine mode (create skeleton or update file). + + + + + + Sorts the Element nodes when True. + + + + + + [?] + + + + + + Suppress Errors sections? + + + + + + Suppress SeeAlso sections? + + + + + + Suppress subroutine parameter entries? + + + + + + Suppress Elements for protected class members? + + + + + + Suppress Elements for private class members? + + + + + + Suppress Elements for function results? + + + + + + Generate class separator comment? + + + + + + The MakeSkel engine, used to create documentation skeleton or update files. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Writes the skeleton or update elements for AFileName into the XML text file. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The general commandline options for MakeSkel. + + + + + + Type of an OnOption handler for unknown commanline options. + + + + + + + + + + + + + + + + + + The action to perform after all FPDoc commandline options have been parsed. + + + + + + + + + + + + + + + + + + + + + + + + + + FPDoc and MakeSkel functionality as a class. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creates or updates XML documentation sources. + + + + + + + + + + + + + + + + + + + + + + + + + + + Creates final documentation, for a package or a single unit. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Adds files in a directory to a stringlist, using a filename mask. + + + + + + + + + + + + + + + + + + + Adds lines from an file to a stringlist. + + + + + + + + + + + + + + + Returns the full input specification (command options) for a unit in the selected package. + + + + + + + + + + + + + + + Returns the package name from an Imports specifier. + + + + + + + + + + + + + Standard OnLog handler, writing to stdout. + + + + + + + + + + + + + + + Standard OnLog handler, writing to stderr. + + + + + + + + + + + + + + + Parses and stores an FPDoc commanline option. + + + + + + + + + + + + + + + Parses and stores an MakeSkel commanline option. + + + + + + + + + + + + + + + Sanity check before starting a MakeSkel operation (DocumentPackage). + + + + + + + + + + + + + + + + + + + + + + + + + + Returns the currently selected package. + + + + + + + + + + + The currently selected package. + + + + + + Action to perform after commandline arguments have been parsed. + + + + + + Allows to perform syntax checks of documentation source files, instead of creating final documentation. + + + + + + True when a project file has been read (--project option) + + + + + + The name of an project file to create (--write-project argument) + + + + + + User supplied handler for unknown commandline options. + + + + + + The directory containing Inputs files. Writing adds all source files in the directory to Inputs[]. + + + + + + The directory containing Description files. Writing adds all XML files in the directory to Descriptions[]. + + + + + + Holds all parsed FPDoc and MakeSkel commandline options. + + + + + + Extracts next commandline option from an string. + + + + + + + + + + + + + + + Get package name from an Imports specifier. + + + + + + + + + + + + + + + Get an filename from an Inputs or Descriptions list. + + + + + + + + + + + + + + + + + + + Get the unit name from Inputs or Descriptions, or from an string containing such an element. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/fpdocmanager/docs/umanager.xml b/examples/fpdocmanager/docs/umanager.xml new file mode 100644 index 0000000000..68243f55fd --- /dev/null +++ b/examples/fpdocmanager/docs/umanager.xml @@ -0,0 +1,1021 @@ + + + + + + The documentation manager. + + + + Interface between the documentation manager and FPDoc engines. + + + + + + + TDocPackage describes a package documentation project. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The INI file for this package. + + + + + + + + + + + + + + + + + + + + + + + + + + + Configures an engine for this project, optionally creates an project file. + + + + + + + + + + + + + + + + + + + Init from TFPDocPackage, into which project AFile has been loaded. + + + + + + + + + + + + + + + + + + + + + + + Write package config. + + + + + + + Returns the INI filename for this package. + + + + + + + + + + + The package name. Writing loads the package INI file. + + + + + + Setting to True registers the package with the Manager, and updates the config file. + + + + + + The XML project file. Writing also sets ProjectDir. + + + + + + Adds an unit to the package, from an --input specifier. + + + + + + + + + + + Common compiler options, extracted from an .lpk file. + + + + + + The Lazarus package file, from which the package is created. + + + + + + The project directory, required to resolve relative file references. + + + + + + Description directory, where new skeletons are created. + + + + + + The list of all description files. When empty, all files in DescrDir are used. + + + + + + Input file directory (unused?) + + + + + + The units belonging to the package. + + + + + + Packages required by this package (names only). + + + + + + -Fi specifiers. + + + + + + -Fu specifiers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sets the current directory as appropriate for relative file references. + + + + + + + + + + + + + + + + + + + + + + + + + + Imports an FPDoc commandline from an script file. + + + + + + + + + + + + + + + Performs FPDoc tests on a package or single unit. + + + + + + + + + + + + + + + + + + + Creates skeletons or updates for a package or a single unit. + + + + + + + + + + + + + + + + + + + The project root directory, required to resolve relative file references. + + + + + + Type of an message output handler (dupe of PParser handler type). + + + + + + + + + + + + + + Documentation manager class, holding packages and common settings. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The global INI file. + + + + + + + + + + + + + + + + + + + + + + + + Blocks nested application update events. + + + + + + + Unlock nested updates, finally invokes the OnChange handler. + + + + + + + Try load config and all packages, when INI file found. + + + + + + + + + + + + + + + + + + + Dummy procedure for now, should flush an Dirty INI file. + + + + + + + + + + + Adds a (new) package project and initializes it from the project file, if not already Loaded. + + + + + + + + + + + + + + + + + + + + + + + Asks the DocPackage to create an projectfile. + + + + + + + + + + + + + + + + + + + Return the named package, create a new one if not found. + + + + + + + + + + + + + + + Imports an Lazarus package or program project file. + + + + + + + + + + + + + + + Add a package, just created from cmdline or projectfile. + + + + + + + + + + + + + + + Create a package from a script, containing an FPDoc commandline. + + + + + + + + + + + + + + + Test a package or single unit documentation. + + + + + + + + + + + + + + + + + + + Update documentation file(s) of a package or single unit (MakeSkel). + + + + + + + + + + + + + + + + + + + Free Pascal documentation directory for RTL and FCL. + + + + + + + + + + + + The global documentation directory, containing all INI files and final documents. + + + + + + The registered packages. + + + + + + The currently processed package. + + + + + + Triggers OnChange event on last EndUpdate. + + + + + + Application handler for changes (added packages). + + + + + + Application handler for log messages. + + + + + + The global documentation manager object. + + + + + + + diff --git a/examples/fpdocmanager/fmain.lfm b/examples/fpdocmanager/fmain.lfm index 9696ab0d57..4b48592148 100644 --- a/examples/fpdocmanager/fmain.lfm +++ b/examples/fpdocmanager/fmain.lfm @@ -28,7 +28,7 @@ object Main: TMain Height = 270 Top = 0 Width = 317 - ActivePage = TabSheet2 + ActivePage = ViewUnits Align = alClient TabIndex = 1 TabOrder = 1 @@ -483,6 +483,7 @@ object Main: TMain '' ) VisibleSpecialChars = [vscSpace, vscTabAtLast] + ScrollBars = ssAutoBoth BracketHighlightStyle = sbhsBoth inline SynLeftGutterPartList1: TSynGutterPartList object SynGutterMarks1: TSynGutterMarks @@ -519,7 +520,7 @@ object Main: TMain end end end - object TabSheet2: TTabSheet + object ViewUnits: TTabSheet Caption = 'Units' ClientHeight = 242 ClientWidth = 309 @@ -635,6 +636,23 @@ object Main: TMain end end end + object ViewINI: TTabSheet + Caption = 'INI' + ClientHeight = 242 + ClientWidth = 309 + object edINI: TMemo + Left = 0 + Height = 242 + Top = 0 + Width = 309 + Align = alClient + Lines.Strings = ( + 'edINI' + ) + ScrollBars = ssAutoBoth + TabOrder = 0 + end + end end object MainMenu1: TMainMenu left = 10 diff --git a/examples/fpdocmanager/fmain.pas b/examples/fpdocmanager/fmain.pas index 25968dae6e..1a73a818a2 100644 --- a/examples/fpdocmanager/fmain.pas +++ b/examples/fpdocmanager/fmain.pas @@ -26,6 +26,7 @@ type buShowLog: TButton; buTest: TButton; dlgSelLpk: TOpenDialog; + edINI: TMemo; swShowUpdate: TCheckBox; edLog: TEdit; lbPackages: TComboBox; @@ -40,13 +41,14 @@ type MenuItem3: TMenuItem; mnExit: TMenuItem; dlgSelRoot: TSelectDirectoryDialog; + ViewINI: TTabSheet; Units: TPageControl; swAll: TRadioButton; swSingle: TRadioButton; edXML: TSynEdit; SynXMLSyn1: TSynXMLSyn; ViewXML: TTabSheet; - TabSheet2: TTabSheet; + ViewUnits: TTabSheet; procedure buRefreshClick(Sender: TObject); procedure buTestClick(Sender: TObject); procedure edLogChange(Sender: TObject); @@ -83,9 +85,9 @@ var implementation uses - fConfig, fLogView, fUpdateView, + fConfig, fLogView, fUpdateView; //dw_HTML, //more writers? - uLpk; + //uLpk; {$R *.lfm} @@ -288,6 +290,9 @@ begin fn := pkg.ProjectFile; //initialized where? if fn <> '' then edXML.Lines.LoadFromFile(fn); + fn := pkg.IniFileName; + if FileExists(fn) then + edINI.Lines.LoadFromFile(fn); //load units... lbUnits.Items.BeginUpdate; lbUnits.Clear; diff --git a/examples/fpdocmanager/fpdocengine.lpk b/examples/fpdocmanager/fpdocengine.lpk index b993e356b9..84ffab1b35 100644 --- a/examples/fpdocmanager/fpdocengine.lpk +++ b/examples/fpdocmanager/fpdocengine.lpk @@ -3,7 +3,9 @@ + + @@ -18,6 +20,7 @@ + @@ -93,6 +96,7 @@ + diff --git a/examples/fpdocmanager/ulpk.pp b/examples/fpdocmanager/ulpk.pp index b7d16a8c6c..7fd352c1de 100644 --- a/examples/fpdocmanager/ulpk.pp +++ b/examples/fpdocmanager/ulpk.pp @@ -25,7 +25,8 @@ function ImportLpk(const AFile: string): TDocPackage; implementation -//uses +uses + umakeskel; type eKey = (kvEof, kvName, kvIncl, kvOther, kvFilename, kvDocPaths, kvReq, kvTitle @@ -43,11 +44,18 @@ var lt, eq, q2: integer; key: eKey; -function ImportCompiled(const LpkFile: string): boolean; +function ImportCompiled(const LpkFile: string; APkg: TDocPackage): boolean; var mfc: string; f: TextFile; begin +(* Makefile.compiled is an XML file, containing + extract -Fi and other options. + -Fu is quite unusable, contains units/%(CPU_TARGET)-%(OS_TARGET) + other options seem omittable? + + Try use .compiled in unit output dir? +*) mfc := ExtractFilePath(LpkFile) + 'Makefile.compiled'; Result := FileExists(mfc); if not Result then @@ -57,9 +65,22 @@ begin Reset(f); try //parse - ReadLn(f, ln); - //todo... - //ImportCommandline (CmdToPrj?) + while not EOF(f) do begin + ReadLn(f, ln); + if Pos(' '' do begin + value := GetNextWord(ln); + if (Copy(value,1,2) = '-d') or (Copy(value,1,3) = '-Fi') then begin + APkg.CompOpts := value; //collects all options + end; + end; + //todo... + end; finally CloseFile(f); end; @@ -141,6 +162,7 @@ begin finally CloseFile(f); end; + ImportCompiled(AFile, pkg); //ignore result, is optional end; end. diff --git a/examples/fpdocmanager/umakeskel.pas b/examples/fpdocmanager/umakeskel.pas index b1353d1c36..be30d20afa 100644 --- a/examples/fpdocmanager/umakeskel.pas +++ b/examples/fpdocmanager/umakeskel.pas @@ -656,7 +656,7 @@ end; function TFPDocMaker.UnitSpec(AUnit: string): string; var i: integer; - s, w: string; + w: string; begin for i := 0 to SelectedPackage.Inputs.Count - 1 do begin w := ExtractUnitName(FPackage.Inputs, i); @@ -955,6 +955,7 @@ var Cmd, Arg: String; begin Cmd:=S; + Arg := ''; //make compiler happy Result := ParseCommon(Cmd, Arg); if Result <> caInvalid then exit; @@ -1094,11 +1095,11 @@ end; function TFPDocMaker.ParseUpdateOption(const s: String): TCreatorAction; -//procedure ParseOption(const s: String; Options: TEngineOptions); var Cmd, Arg: String; begin Cmd:=S; + Arg := ''; //make compiler happy Result := ParseCommon(Cmd, Arg); if Result <> caInvalid then exit; diff --git a/examples/fpdocmanager/umanager.pas b/examples/fpdocmanager/umanager.pas index 357b66a739..8becfc4a20 100644 --- a/examples/fpdocmanager/umanager.pas +++ b/examples/fpdocmanager/umanager.pas @@ -34,6 +34,7 @@ type *) TDocPackage = class private + FCompOpts: string; FDescrDir: string; FDescriptions: TStrings; FIncludePath: string; @@ -46,6 +47,7 @@ type FRequires: TStrings; FUnitPath: string; FUnits: TStrings; + procedure SetCompOpts(AValue: string); procedure SetDescrDir(AValue: string); procedure SetDescriptions(AValue: TStrings); procedure SetIncludePath(AValue: string); @@ -61,6 +63,7 @@ type protected Config: TIniFile; procedure ReadConfig; + function IniFileName: string; public constructor Create; destructor Destroy; override; @@ -72,6 +75,7 @@ type property ProjectFile: string read FProjectFile write SetProjectFile; //xml? //from LazPkg procedure AddUnit(const AFile: string); + property CompOpts: string read FCompOpts write SetCompOpts; property LazPkg: string read FLazPkg write SetLazPkg; //LPK name? property ProjectDir: string read FProjectDir write SetProjectDir; property DescrDir: string read FDescrDir write SetDescrDir; @@ -91,7 +95,6 @@ type TFPDocHelper = class(TFPDocMaker) private FProjectDir: string; - procedure CleanXML(const FileName: string); procedure SetProjectDir(AValue: string); public InputList, DescrList: TStringList; //still required? @@ -138,7 +141,7 @@ type Procedure DoLog(Const Msg : String); public Config: TIniFile; //extend class? - constructor Create(AOwner: TComponent); + constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure BeginUpdate; procedure EndUpdate; @@ -156,7 +159,7 @@ type function Update(APkg: TDocPackage; const AUnit: string): boolean; public //published? property FpcDocDir: string read FFPDocDir write SetFPDocDir; - property LazarusDir: string read FLazarusDir write SetLazarusDir; + //property LazarusDir: string read FLazarusDir write SetLazarusDir; property RootDir: string read FRootDir write SetRootDir; property Packages: TStrings read FPackages; property Package: TDocPackage read FPackage write SetPackage; @@ -185,6 +188,18 @@ begin FDescrDir:=AValue; end; +procedure TDocPackage.SetCompOpts(AValue: string); +begin +(* collect all compiler options +*) + if FCompOpts=AValue then Exit; + if AValue = '' then exit; + if FCompOpts = '' then + FCompOpts:=AValue + else + FCompOpts:= FCompOpts + ' ' + AValue; +end; + procedure TDocPackage.SetDescriptions(AValue: TStrings); (* Shall we allow for multiple descriptions? (general + OS specific!?) *) @@ -212,17 +227,20 @@ begin Import; end; +(* Requires[] only contain package names. + Internal use: Get/Set CommaText +*) procedure TDocPackage.SetRequires(AValue: TStrings); procedure Import; var - i, j: integer; + i: integer; s: string; begin FRequires.Clear; //assume full replace for i := 0 to AValue.Count - 1 do begin s := AValue[i]; //, - FRequires.Add(ExtractImportName(s) + '=' + s); + FRequires.Add(ExtractImportName(s)); // + '=' + s); end; end; @@ -230,10 +248,12 @@ begin if FRequires=AValue then Exit; if AValue = nil then exit; if AValue.Count = 0 then exit; +{ if Pos('=', AValue[0]) > 0 then FRequires.Assign(AValue) //clears previous content else - Import; +} + Import; end; procedure TDocPackage.SetUnits(AValue: TStrings); @@ -361,21 +381,25 @@ begin //todo: common options? OS options? for i := 0 to Units.Count - 1 do begin s := Units.ValueFromIndex[i]; + if CompOpts <> '' then + s := s + ' ' + CompOpts; //add further options? pkg.Inputs.Add(s); end; -//add Descriptions - if DescrDir <> '' then begin +//add Descriptions - either explicit or implicit + if (DescrDir <> '') and (Descriptions.Count = 0) then begin //first check for existing directory if not DirectoryExists(DescrDir) then begin MkDir(DescrDir); //exclude \? end else if Descriptions.Count = 0 then begin APrj.ParseFPDocOption('--descr-dir=' + DescrDir); //adds all XML files end; - end; - for i := 0 to Descriptions.Count - 1 do begin - s := Descriptions[i]; - pkg.Descriptions.Add(s); + end else begin + APrj.DescrDir := DescrDir; //needed by Update + for i := 0 to Descriptions.Count - 1 do begin + s := Descriptions[i]; + pkg.Descriptions.Add(s); + end; end; //add Imports for i := 0 to Requires.Count - 1 do begin @@ -401,7 +425,6 @@ end; *) function TDocPackage.ImportProject(APrj: TFPDocHelper; APkg: TFPDocPackage; const AFile: string): boolean; var - j: integer; s: string; begin //check loaded @@ -441,7 +464,7 @@ begin if Loaded then exit; if Config = nil then - Config := TIniFile.Create(Manager.RootDir + Name + '.ini'); + Config := TIniFile.Create(IniFileName); //check config s := Config.ReadString(SecDoc, 'projectdir', ''); if s = '' then begin @@ -450,6 +473,7 @@ begin end; ProjectFile := Config.ReadString(SecDoc, 'projectfile', ''); FInputDir := Config.ReadString(SecDoc, 'inputdir', ''); + FCompOpts := Config.ReadString(SecDoc, 'options', ''); FDescrDir := Config.ReadString(SecDoc, 'descrdir', ''); Requires.CommaText := Config.ReadString(SecDoc, 'requires', ''); //units @@ -475,16 +499,15 @@ procedure TDocPackage.UpdateConfig; end; end; -var - i: integer; begin //create ini file, if not already created if Config = nil then - Config := TIniFile.Create(Manager.RootDir + Name + '.ini'); //in document RootDir + Config := TIniFile.Create(IniFileName); //in document RootDir //general information Config.WriteString(SecDoc, 'projectdir', ProjectDir); Config.WriteString(SecDoc, 'projectfile', ProjectFile); Config.WriteString(SecDoc, 'inputdir', InputDir); + Config.WriteString(SecDoc, 'options', CompOpts); Config.WriteString(SecDoc, 'descrdir', DescrDir); Config.WriteString(SecDoc, 'requires', Requires.CommaText); //units @@ -494,6 +517,11 @@ begin Loaded := True; end; +function TDocPackage.IniFileName: string; +begin + Result := Manager.RootDir + Name + '.ini'; +end; + procedure TDocPackage.AddUnit(const AFile: string); var s: string; @@ -606,7 +634,6 @@ function TFPDocManager.LoadConfig(const ADir: string; Force: boolean): boolean; var s, pf, cf: string; i: integer; - pkg: TDocPackage; begin s := IncludeTrailingPathDelimiter(ADir); cf := s + ConfigName; @@ -652,6 +679,7 @@ begin (* Protection against excessive saves requires a subclass of TIniFile, which flushes the file only if Dirty. *) + Result := True; //for now end; (* Add a DocPackage to Packages and INI. @@ -784,8 +812,6 @@ begin end; function TFPDocManager.ImportLpk(const AFile: string): TDocPackage; -var - s: string; begin BeginUpdate; //import the LPK file into? Here: TDocPackage, could be FPDocProject? @@ -793,12 +819,7 @@ begin if Result = nil then DoLog('Import failed on ' + AFile) else begin - //todo: ImportCompiled - where? - //RegisterPackage(Result); - Result.Loaded := True; //should write config file!? - //CreateProject(AFile, Result); - //FModified := True; //always? - //Changed; + Result.Loaded := True; //import and write config file end; EndUpdate; end; @@ -855,6 +876,9 @@ function TFPDocManager.Update(APkg: TDocPackage; const AUnit: string): boolean; begin BeginTest(APkg.ProjectFile); try + Result := APkg.CreateProject(Helper, ''); //only configure, don't create file + if not Result then + exit; Result := Helper.Update(APkg, AUnit); finally EndTest; @@ -886,8 +910,6 @@ end; (* Prepare MakeSkel on temporary FPDocPackage *) function TFPDocHelper.BeginTest(APkg: TDocPackage): boolean; -var - pf: string; begin if not assigned(APkg) then exit(False); @@ -956,8 +978,6 @@ begin end; function TFPDocHelper.TestRun(APkg: TDocPackage; AUnit: string): boolean; -var - pf, dir: string; begin (* more detailed error handling? Must CD to the project file directory!? @@ -990,10 +1010,12 @@ function TFPDocHelper.Update(APkg: TDocPackage; const AUnit: string): boolean; InputList.Clear; InputList.Add(UnitSpec(AUnit)); DescrList.Clear; - OutName := DescrDir + AUnit + '.xml'; + OutName := AUnit + '.xml'; + if DescrDir <> '' then + OutName := IncludeTrailingBackslash(DescrDir) + OutName; Options.UpdateMode := FileExists(OutName); if Options.UpdateMode then begin - DescrList.Add(APkg.DescrDir + AUnit + '.xml'); + DescrList.Add(OutName); OutName:=Manager.RootDir + 'upd.' + AUnit + '.xml'; DoLog('Update ' + OutName); end else begin @@ -1026,31 +1048,6 @@ begin EndTest; end; -(* Kill file if no " 0 then - exit; //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.'); -end; - procedure TFPDocHelper.SetProjectDir(AValue: string); begin if FProjectDir=AValue then Exit;