IDE: packages: added option to set the fpdoc package name

git-svn-id: trunk@34823 -
This commit is contained in:
mattias 2012-01-20 16:58:15 +00:00
parent dedcacd54d
commit b83e461a60
6 changed files with 160 additions and 58 deletions

View File

@ -272,9 +272,10 @@ type
);
function GetIDESrcFPDocPath: string; // $(LazarusDir)/docs/xml/ide/
function IsIDESrcFile(const SrcFilename: string): boolean;
function FindModuleOwner(const Modulename: string): TObject;
function FindFPDocPackageOwner(const PackageName: string): TObject;
function FindModuleOwner(FPDocFile: TLazFPDocFile): TObject;
function GetModuleOwnerName(TheOwner: TObject): string;
function GetFPDocPackageNameByOwner(TheOwner: TObject): string;
function ExpandFPDocLinkID(const LinkID, DefaultUnitName,
DefaultOwnerName: string): string;
function ExpandFPDocLinkID(const LinkID, DefaultUnitName: string;
@ -1157,14 +1158,14 @@ begin
if AProject.FPDocPaths='' then
AProject.FPDocPaths:=SelectNewFPDocPaths(AProject.ShortDescription,BaseDir);
FPDocPaths:=AProject.FPDocPaths;
FPDocPackageName:=GetModuleOwnerName(AProject);
FPDocPackageName:=GetFPDocPackageNameByOwner(AProject);
end else if NewOwner is TLazPackage then begin
APackage:=TLazPackage(NewOwner);
BaseDir:=APackage.DirectoryExpanded;
if APackage.FPDocPaths='' then
APackage.FPDocPaths:=SelectNewFPDocPaths(APackage.Name,BaseDir);
FPDocPaths:=APackage.FPDocPaths;
FPDocPackageName:=GetModuleOwnerName(APackage);
FPDocPackageName:=GetFPDocPackageNameByOwner(APackage);
end else if NewOwner=LazarusHelp then begin
BaseDir:=EnvironmentOptions.LazarusDirectory;
FPDocPaths:=GetIDESrcFPDocPath;
@ -1730,23 +1731,29 @@ begin
Result:=true;
end;
function TCodeHelpManager.FindModuleOwner(const Modulename: string): TObject;
function TCodeHelpManager.FindFPDocPackageOwner(const PackageName: string
): TObject;
var
AProject: TLazProject;
i: Integer;
Pkg: TLazPackage;
begin
// check project
AProject:=LazarusIDE.ActiveProject;
if (AProject<>nil)
and (SysUtils.CompareText(GetModuleOwnerName(AProject),Modulename)=0)
and (SysUtils.CompareText(GetFPDocPackageNameByOwner(AProject),PackageName)=0)
then begin
Result:=AProject;
exit;
end;
// check package
Result:=PackageGraph.FindPackageWithName(Modulename,nil);
if Result<>nil then exit;
for i:=0 to PackageGraph.Count-1 do begin
Pkg:=PackageGraph[i];
if SysUtils.CompareText(Pkg.GetFPDocPackageName,PackageName)=0 then
exit(Pkg);
end;
// check IDE as project
if SysUtils.CompareText(IDEProjectName,Modulename)=0 then begin
if SysUtils.CompareText(IDEProjectName,PackageName)=0 then begin
Result:=LazarusHelp;
exit;
end;
@ -1845,13 +1852,26 @@ begin
Result:='';
end;
function TCodeHelpManager.GetFPDocPackageNameByOwner(TheOwner: TObject
): string;
begin
if TheOwner is TLazPackage then
Result:=TLazPackage(TheOwner).GetFPDocPackageName
else if TheOwner is TLazProject then
Result:=ExtractFileNameOnly(TLazProject(TheOwner).ProjectInfoFile)
else if TheOwner=LazarusHelp then
Result:=IDEProjectName
else
Result:='';
end;
function TCodeHelpManager.ExpandFPDocLinkID(const LinkID, DefaultUnitName,
DefaultOwnerName: string): string;
begin
Result:=LinkID;
if (LinkID='') or (LinkID[1]='#') then exit;
Result:=ExpandFPDocLinkID(LinkId,DefaultUnitName,
FindModuleOwner(DefaultOwnerName));
FindFPDocPackageOwner(DefaultOwnerName));
end;
function TCodeHelpManager.ExpandFPDocLinkID(const LinkID,

View File

@ -383,11 +383,11 @@ type
FSessionModified: boolean;
FTitle: String;
FSessionStorage: TProjectSessionStorage;
FLazDocPaths: string;
FFPDocPaths: string;
FUseAppBundle: Boolean;
procedure SetCleanOutputFileMask(const AValue: string);
procedure SetCleanSourcesFileMask(const AValue: string);
procedure SetLazDocPaths(const AValue: string);
procedure SetFPDocPaths(const AValue: string);
protected
FLazCompilerOptions: TLazCompilerOptions;
FFlags: TProjectFlags;
@ -454,7 +454,8 @@ type
write SetSessionModified;
// project session data (not units, data),
// units have their own SessionModified
property LazDocPaths: string read FLazDocPaths write SetLazDocPaths;
property FPDocPaths: string read FFPDocPaths write SetFPDocPaths;
property LazDocPaths: string read FFPDocPaths write SetFPDocPaths; deprecated;
property CleanOutputFileMask: string read FCleanOutputFileMask write SetCleanOutputFileMask; // saved in session
property CleanSourcesFileMask: string read FCleanSourcesFileMask write SetCleanSourcesFileMask; // saved in session
property CustomData: TStringToStringTree read FCustomData;
@ -1046,10 +1047,10 @@ begin
SessionModified:=true;
end;
procedure TLazProject.SetLazDocPaths(const AValue: string);
procedure TLazProject.SetFPDocPaths(const AValue: string);
begin
if FLazDocPaths=AValue then exit;
FLazDocPaths:=AValue;
if FFPDocPaths=AValue then exit;
FFPDocPaths:=AValue;
Modified:=true;
end;
@ -1112,7 +1113,7 @@ begin
FExecutableType:=petNone;
FTitle:='';
FSessionStorage:=DefaultNewProjectSessionStorage;
FLazDocPaths:='';
FFPDocPaths:='';
end;
function TLazProject.ShortDescription: string;

View File

@ -72,33 +72,79 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
)
TabOrder = 1
end
object LazDocGroupBox: TGroupBox[2]
object DocGroupBox: TGroupBox[2]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = UpdateRadioGroup
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 52
Height = 82
Top = 236
Width = 461
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'LazDoc - Lazarus documentation'
ClientHeight = 36
Caption = 'FPDoc settings'
ClientHeight = 66
ClientWidth = 457
TabOrder = 2
object LazDocPathEdit: TEdit
AnchorSideLeft.Control = LazDocGroupBox
AnchorSideTop.Control = LazDocGroupBox
Left = 6
object FPDocSearchPathsEdit: TEdit
AnchorSideLeft.Control = FPDocSearchPathsLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DocGroupBox
AnchorSideRight.Control = DocGroupBox
AnchorSideRight.Side = asrBottom
Left = 146
Height = 24
Top = 6
Width = 365
Width = 305
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ParentShowHint = False
ShowHint = True
TabOrder = 0
Text = 'FPDocSearchPathsEdit'
end
object FPDocSearchPathsLabel: TLabel
AnchorSideLeft.Control = DocGroupBox
AnchorSideTop.Control = FPDocSearchPathsEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 11
Width = 134
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'FPDocSearchPathsLabel'
ParentColor = False
end
object FPDocPackageNameLabel: TLabel
AnchorSideLeft.Control = DocGroupBox
AnchorSideTop.Control = FPDocPackageNameEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 41
Width = 145
BorderSpacing.Left = 6
Caption = 'FPDocPackageNameLabel'
ParentColor = False
end
object FPDocPackageNameEdit: TEdit
AnchorSideLeft.Control = FPDocPackageNameLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FPDocSearchPathsEdit
AnchorSideTop.Side = asrBottom
Left = 157
Height = 24
Top = 36
Width = 116
BorderSpacing.Around = 6
ParentShowHint = False
ShowHint = True
TabOrder = 1
Text = 'FPDocPackageNameEdit'
end
end
end

View File

@ -14,14 +14,17 @@ type
{ TPackageIntegrationOptionsFrame }
TPackageIntegrationOptionsFrame = class(TAbstractIDEOptionsEditor)
LazDocGroupBox: TGroupBox;
LazDocPathEdit: TEdit;
FPDocPackageNameEdit: TEdit;
FPDocPackageNameLabel: TLabel;
FPDocSearchPathsLabel: TLabel;
DocGroupBox: TGroupBox;
FPDocSearchPathsEdit: TEdit;
PkgTypeRadioGroup: TRadioGroup;
UpdateRadioGroup: TRadioGroup;
procedure PkgTypeRadioGroupClick(Sender: TObject);
private
FLazPackage: TLazPackage;
LazDocPathButton: TPathEditorButton;
FPDocPathButton: TPathEditorButton;
FStoredPkgType: Integer;
procedure PathEditBtnClick(Sender: TObject);
procedure PathEditBtnExecuted(Sender: TObject);
@ -61,7 +64,7 @@ procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject);
var
AButton: TPathEditorButton absolute Sender;
begin
AButton.CurrentPathEditor.Path := LazDocPathEdit.Text;
AButton.CurrentPathEditor.Path := FPDocSearchPathsEdit.Text;
AButton.CurrentPathEditor.Templates := '';
end;
@ -78,7 +81,7 @@ begin
if AButton.CurrentPathEditor.ModalResult <> mrOk then
Exit;
NewPath := AButton.CurrentPathEditor.Path;
OldPath := LazDocPathEdit.Text;
OldPath := FPDocSearchPathsEdit.Text;
if OldPath <> NewPath then
begin
// check NewPath
@ -113,7 +116,7 @@ begin
end;
until StartPos > length(NewPath);
end;
LazDocPathEdit.Text := NewPath;
FPDocSearchPathsEdit.Text := NewPath;
end;
function TPackageIntegrationOptionsFrame.GetTitle: string;
@ -132,23 +135,28 @@ begin
UpdateRadioGroup.Items[0] := lisPckOptsAutomaticallyRebuildAsNeeded;
UpdateRadioGroup.Items[1] := lisPckOptsAutoRebuildWhenRebuildingAll;
UpdateRadioGroup.Items[2] := lisPckOptsManualCompilationNeverAutomatically;
LazDocGroupBox.Caption := lisCodeHelpPathsGroupBox;
DocGroupBox.Caption := lisCodeHelpGroupBox;
LazDocPathButton := TPathEditorButton.Create(Self);
with LazDocPathButton do
FPDocPackageNameLabel.Caption:=lisPckPackage;
FPDocPackageNameEdit.Hint:=lisPckClearToUseThePackageName;
FPDocSearchPathsLabel.Caption:=lisPathEditSearchPaths;
FPDocSearchPathsEdit.Hint:=lisPckSearchPathsForFpdocXmlFilesMultiplePathsMustBeSepa;
FPDocPathButton := TPathEditorButton.Create(Self);
with FPDocPathButton do
begin
Name := 'LazDocPathButton';
Name := 'FPDocPathButton';
Caption := '...';
AutoSize := True;
Anchors := [akRight];
AnchorParallel(akRight, 6, LazDocGroupBox);
AnchorParallel(akTop, 0, LazDocPathEdit);
AnchorParallel(akBottom, 0, LazDocPathEdit);
AnchorParallel(akRight, 6, DocGroupBox);
AnchorParallel(akTop, 0, FPDocSearchPathsEdit);
AnchorParallel(akBottom, 0, FPDocSearchPathsEdit);
OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted;
Parent := LazDocGroupBox;
Parent := DocGroupBox;
end;
LazDocPathEdit.AnchorToNeighbour(akRight, 0, LazDocPathButton);
FPDocSearchPathsEdit.AnchorToNeighbour(akRight, 0, FPDocPathButton);
end;
procedure TPackageIntegrationOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -167,7 +175,8 @@ begin
else
UpdateRadioGroup.ItemIndex := 2;
end;
LazDocPathEdit.Text := LazPackage.LazDocPaths;
FPDocSearchPathsEdit.Text:=LazPackage.FPDocPaths;
FPDocPackageNameEdit.Text:=LazPackage.FPDocPackageName;
end;
function TPackageIntegrationOptionsFrame.ShowMsgPackageTypeMustBeDesign: boolean;
@ -214,7 +223,8 @@ begin
else
LazPackage.AutoUpdate := pupAsNeeded;
end;
LazPackage.LazDocPaths := LazDocPathEdit.Text;
LazPackage.FPDocPaths := FPDocSearchPathsEdit.Text;
LazPackage.FPDocPackageName := FPDocPackageNameEdit.Text;
end;
class function TPackageIntegrationOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;

View File

@ -567,6 +567,7 @@ type
FAutoCreated: boolean;
FAutoInstall: TPackageInstallType;
FAutoUpdate: TPackageUpdatePolicy;
FFPDocPackageName: string;
FOptionsBackup: TLazPackage;
FCompilerOptions: TPkgCompilerOptions;
FComponents: TFPList; // TFPList of TPkgComponent
@ -588,7 +589,7 @@ type
FHoldPackageCount: integer;
FIconFile: string;
FInstalled: TPackageInstallType;
FLazDocPaths: string;
FFPDocPaths: string;
FLicense: string;
FLPKSource: TCodeBuffer;
FLPKSourceChangeStep: integer;
@ -627,9 +628,10 @@ type
procedure SetEnableI18NForLFM(AValue: boolean);
procedure SetFileReadOnly(const AValue: boolean);
procedure SetFlags(const AValue: TLazPackageFlags);
procedure SetFPDocPackageName(AValue: string);
procedure SetIconFile(const AValue: string);
procedure SetInstalled(const AValue: TPackageInstallType);
procedure SetLazDocPaths(const AValue: string);
procedure SetFPDocPaths(const AValue: string);
procedure SetLicense(const AValue: string);
procedure SetLPKSource(const AValue: TCodeBuffer);
procedure SetLPKSourceChangeStep(const AValue: integer);
@ -770,6 +772,8 @@ type
function ProvidesPackage(const AName: string): boolean;
// ID
procedure ChangeID(const NewName: string; NewVersion: TPkgVersion);
function GetFPDocPackageName: string;
public
LastCompile: array[TPkgOutputDir] of TPkgLastCompileStats;
function GetOutputDirType: TPkgOutputDir;
@ -807,7 +811,8 @@ type
property HoldPackageCount: integer read FHoldPackageCount;
property IconFile: string read FIconFile write SetIconFile;
property Installed: TPackageInstallType read FInstalled write SetInstalled;
property LazDocPaths: string read FLazDocPaths write SetLazDocPaths;
property FPDocPaths: string read FFPDocPaths write SetFPDocPaths;
property FPDocPackageName: string read FFPDocPackageName write SetFPDocPackageName;
property License: string read FLicense write SetLicense;
property LPKSource: TCodeBuffer read FLPKSource write SetLPKSource;// can be nil when file on disk was removed
property LPKSourceChangeStep: integer read FLPKSourceChangeStep write SetLPKSourceChangeStep;
@ -2292,7 +2297,8 @@ begin
PackageType:=aSource.PackageType;
OutputStateFile:=aSource.OutputStateFile;
License:=aSource.License;
LazDocPaths:=aSource.LazDocPaths;
FPDocPaths:=aSource.FPDocPaths;
FPDocPackageName:=aSource.FPDocPackageName;
IconFile:=aSource.IconFile;
UsageOptions.AssignOptions(aSource.UsageOptions);
EnableI18N:=aSource.EnableI18N;
@ -2427,6 +2433,13 @@ begin
Modified:=true;
end;
procedure TLazPackage.SetFPDocPackageName(AValue: string);
begin
if FFPDocPackageName=AValue then Exit;
FFPDocPackageName:=AValue;
Modified:=true;
end;
procedure TLazPackage.SetIconFile(const AValue: string);
begin
if FIconFile=AValue then exit;
@ -2440,13 +2453,13 @@ begin
FInstalled:=AValue;
end;
procedure TLazPackage.SetLazDocPaths(const AValue: string);
procedure TLazPackage.SetFPDocPaths(const AValue: string);
var
NewValue: String;
begin
NewValue:=TrimSearchPath(AValue,'');
if FLazDocPaths=NewValue then exit;
FLazDocPaths:=NewValue;
if FFPDocPaths=NewValue then exit;
FFPDocPaths:=NewValue;
Modified:=true;
end;
@ -2683,6 +2696,8 @@ begin
FName:='';
FPackageType:=lptRunAndDesignTime;
FRegistered:=false;
FFPDocPaths:='';
FFPDocPackageName:='';
ClearCustomOptions;
end;
for i:=FComponents.Count-1 downto 0 do Components[i].Free;
@ -2825,8 +2840,9 @@ begin
OutputStateFile:=SwitchPathDelims(
XMLConfig.GetValue(Path+'OutputStateFile/Value',''),
PathDelimChanged);
fLazDocPaths:=SwitchPathDelims(XMLConfig.GetValue(Path+'LazDoc/Paths',''),
FFPDocPaths:=SwitchPathDelims(XMLConfig.GetValue(Path+'LazDoc/Paths',''),
PathDelimChanged);
FFPDocPackageName:=XMLConfig.GetValue(Path+'LazDoc/PackageName','');
// i18n
if FileVersion<3 then begin
FPOOutputDirectory := SwitchPathDelims(
@ -2913,7 +2929,8 @@ begin
XMLConfig.SetDeleteValue(Path+'IconFile/Value',f(FIconFile),'');
XMLConfig.SetDeleteValue(Path+'Name/Value',FName,'');
XMLConfig.SetDeleteValue(Path+'OutputStateFile/Value',f(OutputStateFile),'');
XMLConfig.SetDeleteValue(Path+'LazDoc/Paths',f(FLazDocPaths),'');
XMLConfig.SetDeleteValue(Path+'LazDoc/Paths',f(FFPDocPaths),'');
XMLConfig.SetDeleteValue(Path+'LazDoc/PackageName',FFPDocPackageName,'');
XMLConfig.SetDeleteValue(Path+'i18n/EnableI18N/Value', EnableI18N, false);
XMLConfig.SetDeleteValue(Path+'i18n/OutDir/Value',f(FPOOutputDirectory), '');
@ -3566,6 +3583,14 @@ begin
Name:=NewName;
end;
function TLazPackage.GetFPDocPackageName: string;
begin
if FPDocPackageName<>'' then
Result:=FPDocPackageName
else
Result:=Name;
end;
function TLazPackage.GetOutputDirType: TPkgOutputDir;
begin
if (CompilerOptions<>nil)

View File

@ -1535,7 +1535,7 @@ begin
CompilerOptions.UnitOutputDirectory:='$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/';
POOutputDirectory:='languages';
Translated:=SystemLanguageID1;
LazDocPaths:=SetDirSeparators('$(LazarusDir)/docs/xml/lcl');
FPDocPaths:=SetDirSeparators('$(LazarusDir)/docs/xml/lcl');
AddToProjectUsesSection:=false;
// add requirements
@ -1586,7 +1586,7 @@ begin
CompilerOptions.UnitOutputDirectory:='$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgeType)';
POOutputDirectory:='languages';
Translated:=SystemLanguageID1;
LazDocPaths:=SetDirSeparators('$(LazarusDir)/docs/xml/lcl');
FPDocPaths:=SetDirSeparators('$(LazarusDir)/docs/xml/lcl');
AddToProjectUsesSection:=false;
// add requirements
@ -1701,7 +1701,7 @@ begin
CompilerOptions.UnitOutputDirectory:='';
POOutputDirectory:='languages';
Translated:=SystemLanguageID1;
LazDocPaths:=SetDirSeparators('$(LazarusDir)/components/synedit/docs/xml');
FPDocPaths:=SetDirSeparators('$(LazarusDir)/components/synedit/docs/xml');
AddToProjectUsesSection:=false;
// add requirements
@ -1822,7 +1822,7 @@ begin
Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:='';
POOutputDirectory:='languages';
LazDocPaths:='docs';
FPDocPaths:='docs';
Translated:=SystemLanguageID1;
AddToProjectUsesSection:=false;
@ -1864,7 +1864,7 @@ begin
Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:='';
POOutputDirectory:='languages';
LazDocPaths:='docs';
FPDocPaths:='docs';
Translated:=SystemLanguageID1;
AddToProjectUsesSection:=false;
@ -1904,7 +1904,7 @@ begin
Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:='';
POOutputDirectory:='languages';
LazDocPaths:='docs';
FPDocPaths:='docs';
Translated:=SystemLanguageID1;
AddToProjectUsesSection:=false;
@ -1986,7 +1986,7 @@ begin
CompilerOptions.UnitOutputDirectory:='';
POOutputDirectory:='languages';
Translated:=SystemLanguageID1;
LazDocPaths:='docs';
FPDocPaths:='docs';
EnableI18N:=true;
AddToProjectUsesSection:=false;