Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
paule32 committed Jun 12, 2024
1 parent 7392460 commit 1a6d32d
Showing 1 changed file with 158 additions and 26 deletions.
184 changes: 158 additions & 26 deletions doc/src/start.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
// @desc This Pascal script forms a Example chm content project by the
// given files in the "topicFiles" Array as String.
// --------------------------------------------------------------------------
const global_BuildName = 'Help Documentation';
const global_BuildOutput = '.\output';

// hard coded output file path for the help project files:
const pro_path = 'E:\Projekte\HelpNDocTools\doc';
//
const bak_path = pro_path + '\backup';
const out_path = pro_path + '\output';

const prj_name = 'Help Documentation';

// --------------------------------------------------------------------------
// global exception stuff ...
Expand All @@ -21,36 +27,66 @@ type EbuildProject = class(Exception);
// --------------------------------------------------------------------------
// project class stuff ...
// --------------------------------------------------------------------------
type
TCustomEditor = class(TObject)
private
oEditor: TObject; // temporary Editor
oMemory: TMemoryStream;
public
constructor Create;
destructor Destroy; override;

procedure Clear;
end;
type
TDocProject = class(TObject)
private
FActive: Boolean;
FEditor: TCustomEditor;

buildID: String;
buildName: String;
buildKind: TProjectKind;
buildOutput: String;

FProjectKind: TProjectKind;
FProjectName: String; // hid name
FProjectID : String; // internal name
public
constructor Create;
destructor Destroy; override;

procedure setActive(AValue: Boolean);
procedure setActive(AValue: Boolean); overload;
procedure setActive(AValue: String); overload;

procedure setID(AValue: String);
procedure setName(AValue: String);

procedure setKind(AValue: TProjectKind);
procedure setOutput(AValue: String);

procedure setAuthor(AValue: String);
procedure setTitle(AValue: String);
procedure setLang(AValue: String);
procedure setCharset(AValue: String);

procedure setEditor(AValue: TCustomEditor);
function getEditor: TCustomEditor;
function getActive: Boolean;

function getID: String;
function getName: String;

function getKind: TProjectKind;
function getOutput: String;

function getAuthor: String;
function getTitle: String;
function getLang: String;

function getCharset: String;
published
property Active: Boolean read FActive write FActive;
property Editor: TCustomEditor read FEditor write FEditor;
property Kind: TProjectKind read FProjectKind write FProjectKind;
end;
var
doc: TDocProject;
Expand All @@ -64,17 +100,23 @@ TDocProject = class(TObject)
constructor TDocProject.Create;
begin
inherited Create;
printf('info: create: ' + global_BuildName,[]);
FEditor := TCustomEditor.Create;

HndBuilds.DeleteAllBuilds;
THndGeneratorInfo.BOMoutput := false;
HndProjects.NewProject(prj_name);

HndBuilds.DeleteAllBuilds;
setID( HndBuilds.CreateBuild );

setName ( global_BuildName );
setKind ( ptCHM );
setOutput( global_BuildOutput );
setOutput (out_path);
setName (prj_name);
setTitle (prj_help);

HndBuilds.setBuildName( getID, getName );
setCharset(prj_utf8);
setLang (prj_lang);

setKind (ptCHM); // default: CHM
setActive(buildID);
end;

// ----------------------------------------------------------------------------
Expand All @@ -85,10 +127,17 @@ constructor TDocProject.Create;
// ----------------------------------------------------------------------------
destructor TDocProject.Destroy;
begin
printf('info: destroy',[]);
FEditor.Free;
inherited Destroy;
end;

procedure TDocProject.new(AValue: String);
begin
SetLength(FProjectName,Length(AValue));
FProjectName := Copy(AValue, 1, Length(AValue));
FProjectID := NewProject(FProjectName);
end;

// ----------------------------------------------------------------------------
// @brief This procedure set the build ID.
// @param AValue - String.
Expand All @@ -115,8 +164,13 @@ procedure TDocProject.setName(AValue: String);
if Length(Trim(AValue)) < 1 then
raise EbuildProject.Create('project name is empty; so it can not set.');

SetLength(buildName, Length(AValue));
buildName := Copy(AValue, 1, Length(AValue));
if Length(Trim(buildID)) < 1 then
raise EbuildProject.Create('project id is empty.');

SetLength(FProjectName, Length(AValue));
FProjectName := Copy(AValue, 1, Length(AValue));

HndBuilds.setBuildName( getID, getName );
end;

// ----------------------------------------------------------------------------
Expand All @@ -141,10 +195,10 @@ function TDocProject.getID: String;
// ----------------------------------------------------------------------------
function TDocProject.getName: String;
begin
if Length(Trim(buildName)) < 1 then
if Length(Trim(FProjectName)) < 1 then
raise EbuildProject.Create('build name not set.');

result := buildName;
result := FProjectName;
end;

// ----------------------------------------------------------------------------
Expand All @@ -155,7 +209,7 @@ function TDocProject.getName: String;
// ----------------------------------------------------------------------------
procedure TDocProject.setKind(AValue: TProjectKind);
begin
buildKind := AValue;
FProjectKind := AValue;
end;

// ----------------------------------------------------------------------------
Expand All @@ -166,7 +220,7 @@ procedure TDocProject.setKind(AValue: TProjectKind);
// ----------------------------------------------------------------------------
function TDocProject.getKind: TProjectKind;
begin
result := buildKind;
result := FProjectKind;
end;

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -203,9 +257,22 @@ function TDocProject.getOutput: String;
// ----------------------------------------------------------------------------
procedure TDocProject.setActive(AValue: Boolean);
begin
if Length(Trim( buildID )) < 1 then
raise EbuildProject.Create('build ID is empty.');

HndBuilds.setBuildEnabled( buildID, AValue );
FActive := AValue;
end;

procedure TDocProject.setActive(AValue: String);
begin
if Length(Trim( AValue )) < 1 then
raise EbuildProject.Create('build ID is empty.');

HndBuilds.setBuildEnabled( AValue, True );
FActive := True;
end;

// ----------------------------------------------------------------------------
// @brief This function return/get the build state.
// @param Boolean.
Expand All @@ -217,31 +284,96 @@ function TDocProject.getActive: Boolean;
result := FActive;
end;

procedure TDocProject.setEditor(AValue: TCustomEditor);
begin
FEditor := AValue;
end;

function TDocProject.getEditor: TCustomEditor;
begin
result := FEditor;
end;

procedure TDocProject.setAuthor(AValue: String);
begin
end;
procedure TDocProject.setTitle(AValue: String);
begin
end;
procedure TDocProject.setLang(AValue: String);
begin
end;
procedure TDocProject.setCharset(AValue: String);
begin
end;

function TDocProject.getAuthor: String;
begin
result :=
end;
function TDocProject.getTitle: String;
begin
result :=
end;
function TDocProject.getLang: String;
begin
result :=
end;
function TDocProject.getCharset: String;
begin
result :=
end;

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
constructor TCustomEditor.Create;
begin
inherited Create;

oEditor := HndEditor.CreateTemporaryEditor;
oMemory := TMemoryStream.Create;

oMemory.Clear;
Clear;
end;
destructor TCustomEditor.Destroy;
begin
oMemory.Clear;
oMemory.Free;

HndEditor.DestroyTemporaryEditor(oEditor);
inherited Destroy;
end;

procedure TCustomEditor.Clear;
begin
HndEditor.Clear(oEditor);
end;

// ----------------------------------------------------------------------------
// @brief This is the entry point of our project generator.
// ----------------------------------------------------------------------------
begin
try
try
doc := TDocProject.Create;
doc.getID;
doc.kind := ptCHM;

doc.Editor.Clear;
except
on E: EbuildProject do
begin
printf(
'Exception occured:' + #13#10 +
E.Message + #13#10,[]);
printf('Exception occured:' + #13#10 +
E.Message,[]);
end;
on E: Exception do
begin
ShowMessage(
'Exception occured:' + #13#10 +
E.Message);
printf('Exception occured:' + #13#10 +
E.Message,[]);
end;
end
finally
doc.Free;

printf('Done.',[]);
end;
end.

0 comments on commit 1a6d32d

Please sign in to comment.