Skip to content

Commit

Permalink
feat(developer): New Project - Description field and tweaks
Browse files Browse the repository at this point in the history
Fixes #9869.

Adds a 'Description' field, tweaks Copyright strings, and tweaks
default content for documentation to the New Project wizards and
kmconvert.
  • Loading branch information
mcdurdin committed Nov 6, 2023
1 parent 4c5a910 commit 0285993
Show file tree
Hide file tree
Showing 18 changed files with 205 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TImportWindowsKeyboard = class
FCopyright: string;
FTargets: TKeymanTargets;
FFullCopyright: string;
FDescription: string;
function LoadKLIDDetails: Boolean;
function ImportKeyboard(const DestinationFilename, DestinationKVKSFilename: string): Boolean;
function GenerateIcon(const IconFilename: string): Boolean;
Expand All @@ -46,6 +47,7 @@ TImportWindowsKeyboard = class
function GetProjectFilename: string;
procedure SetTargets(const Value: TKeymanTargets);
procedure SetFullCopyright(const Value: string);
procedure SetDescription(const Value: string);
public
function Execute: Boolean; overload;

Expand All @@ -62,6 +64,7 @@ TImportWindowsKeyboard = class
property Version: string read FVersion write SetVersion;
property BCP47Tags: string read FBCP47Tags write SetBCP47Tags;
property Author: string read FAuthor write SetAuthor;
property Description: string read FDescription write SetDescription;
property Targets: TKeymanTargets read FTargets write SetTargets;

property ProjectFilename: string read GetProjectFilename;
Expand Down Expand Up @@ -151,6 +154,11 @@ procedure TImportWindowsKeyboard.SetCopyright(const Value: string);
FCopyright := Value;
end;

procedure TImportWindowsKeyboard.SetDescription(const Value: string);
begin
FDescription := Value;
end;

procedure TImportWindowsKeyboard.SetDestinationPath(const Value: string);
begin
FDestinationPath := IncludeTrailingPathDelimiter(Value);
Expand Down Expand Up @@ -219,6 +227,7 @@ function TImportWindowsKeyboard.Execute: Boolean;
FTemplate.Copyright := FCopyright;
FTemplate.FullCopyright := FFullCopyright;
FTemplate.Author := FAuthor;
FTemplate.Description := FDescription;
FTemplate.Version := FVersion;
FTemplate.IncludeIcon := True;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TKMConvertParameters = record
FModelIdLanguage: string;
FModelIdUniq: string;
FEmitUsage: Boolean;
FDescription: string;

function CheckParam(name, value: string): Boolean;
function SetKLID(const value: string): Boolean;
Expand All @@ -44,6 +45,7 @@ TKMConvertParameters = record
function IsValidModelComponent(const component, value: string): Boolean;
function ValidateBCP47Tag(const component, tag: string): Boolean;
procedure OutputText(const msg: string = '');
function SetDescription(const value: string): Boolean;
public
type TOutputTextProc = reference to procedure(msg: string);
var OnOutputText: TOutputTextProc;
Expand All @@ -62,6 +64,7 @@ TKMConvertParameters = record
property Version: string read FVersion;
property BCP47Tags: string read FBCP47Tags;
property Author: string read FAuthor;
property Description: string read FDescription;
property Targets: TKeymanTargets read FTargets;
property Mode: TKMConvertMode read FMode;
property NoLogo: Boolean read FNoLogo;
Expand Down Expand Up @@ -90,8 +93,8 @@ function TKMConvertParameters.CheckParams(Params: TArray<string>): Boolean;
FEmitUsage := False;

FDestination := '.';
FCopyright := 'Copyright (C)';
FFullCopyright := 'Copyright (C) '+FormatDateTime('yyyy', Now);
FCopyright := 'Copyright '+Char($00A9 {copyright});
FFullCopyright := 'Copyright '+Char($00A9 {copyright})+' '+FormatDateTime('yyyy', Now);
FVersion := '1.0';
FTargets := [ktAny];

Expand Down Expand Up @@ -161,6 +164,7 @@ procedure TKMConvertParameters.WriteUsage;
OutputText(' (in `import-windows` mode, can be a format string)');
OutputText(' -o <destination> The target folder to write the project into, defaults to "."');
OutputText(' -author <data> Name of author of the keyboard/model, no default');
OutputText(' -description <data> Short plain-text description of the keyboard/model, no default');
OutputText(' -name <data> Name of the keyboard/model, e.g. "My First Keyboard", "%s Basic" ');
OutputText(' (format strings are only valid in `import-windows` mode)');
OutputText(' -copyright <data> Copyright string for the keyboard/model, defaults to "Copyright (C)"');
Expand Down Expand Up @@ -189,6 +193,7 @@ function TKMConvertParameters.CheckParam(name, value: string): Boolean;
else if name = '-version' then Result := SetVersion(value)
else if name = '-languages' then Result := SetBCP47Tags(value)
else if name = '-author' then Result := SetAuthor(value)
else if name = '-description' then Result := SetDescription(value)
else if name = '-targets' then Result := SetTargets(value)
else if name = '-id-author' then Result := SetModelIdAuthor(value)
else if name = '-id-language' then Result := SetModelIdLanguage(value)
Expand Down Expand Up @@ -314,6 +319,12 @@ function TKMConvertParameters.SetAuthor(const value: string): Boolean;
Result := True;
end;

function TKMConvertParameters.SetDescription(const value: string): Boolean;
begin
FDescription := Value;
Result := True;
end;

function TKMConvertParameters.SetTargets(const value: string): Boolean;
begin
FTargets := StringToKeymanTargets(Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ procedure TKeyboardProjectTemplate.WriteKPS;
kps.Info.Desc[PackageInfo_Name] := Name;
kps.Info.Desc[PackageInfo_Copyright] := Copyright;
kps.Info.Desc[PackageInfo_Author] := Author;
kps.Info.Desc[PackageInfo_Description] := Description;
kps.KPSOptions.FollowKeyboardVersion := True;
kps.FileName := GetPackageFilename;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function DoImportWindowsKeyboard(FParameters: TKMConvertParameters): Boolean;
iwk.DestinationPath := FParameters.Destination;
iwk.KeyboardIDTemplate := FParameters.KeyboardID;
iwk.NameTemplate := FParameters.Name;
iwk.Description := FParameters.Description;
iwk.Copyright := FParameters.Copyright;
iwk.FullCopyright := FParameters.FullCopyright;
iwk.Version := FParameters.Version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ procedure TModelProjectTemplate.WriteKPS;
kps.Info.Desc[PackageInfo_Copyright] := Copyright;
kps.Info.Desc[PackageInfo_Author] := Author;
kps.Info.Desc[PackageInfo_Version] := Version;
kps.Info.Desc[PackageInfo_Description] := Description;
kps.FileName := GetPackageFilename;

// Add model.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TProjectTemplate = class
FProjectType: TKeymanProjectType;
FTargets: TKeymanTargets;
FFullCopyright: string;
FDescription: string;

protected
const
Expand Down Expand Up @@ -61,6 +62,7 @@ TProjectTemplate = class
property Targets: TKeymanTargets read FTargets;

property Name: string read FName write FName;
property Description: string read FDescription write FDescription;
property Copyright: string read FCopyright write FCopyright;
property FullCopyright: string read FFullCopyright write FFullCopyright;
property Author: string read FAuthor write FAuthor;
Expand Down Expand Up @@ -235,10 +237,12 @@ procedure TProjectTemplate.Transform(const SourceFile: string; DestFile: string
end;

s := ReplaceStr(s, '$NAME', FName);
s := ReplaceStr(s, '$ID', FId);
s := ReplaceStr(s, '$VERSION', FVersion);
s := ReplaceStr(s, '$COPYRIGHT', FCopyright);
s := ReplaceStr(s, '$FULLCOPYRIGHT', FFullCopyright);
s := ReplaceStr(s, '$AUTHOR', FAuthor);
s := ReplaceStr(s, '$DESCRIPTION', FDescription);
s := ReplaceStr(s, '$DATE', FormatDateTime('yyyy-mm-dd', Now));
if Pos('$LANGUAGES_KEYBOARD_INFO', s) > 0 then
s := ReplaceStr(s, '$LANGUAGES_KEYBOARD_INFO', GetLanguageTagListForKeyboardInfo);
Expand Down
5 changes: 2 additions & 3 deletions developer/src/kmconvert/data/basic-keyboard/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
$NAME keyboard
==============

Version $VERSION

Description
-----------
$NAME generated from template
$DESCRIPTION

Links
-----
Keyboard Homepage: https://keyman.com/keyboards/$ID

Copyright
---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>$NAME</h1>

<p>
$NAME $VERSION generated from template.
$DESCRIPTION
</p>

<p>$COPYRIGHT</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>Start Using $NAME</h1>

<p>
$NAME $VERSION generated from template.
$DESCRIPTION
</p>

<h1>Keyboard Layout</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
$NAME lexical model
===================

Version $VERSION

Description
-----------
$NAME generated from template
$DESCRIPTION

Links
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"languages": [
$LANGUAGES_KEYBOARD_INFO
],
"description": "$NAME generated from template"
"description": "$DESCRIPTION"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
$NAME $VERSION generated from template.
$NAME $VERSION
This is a minimal lexical model source that uses a tab delimited wordlist.
See documentation online at https://help.keyman.com/developer/ for
additional parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>$NAME</h1>

<p>
$NAME $VERSION generated from template.
$DESCRIPTION
</p>

<p>$COPYRIGHT</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>Start Using $NAME</h1>

<p>
$NAME $VERSION generated from template.
$DESCRIPTION
</p>

<h1>Wordlist Model Documentation</h1>
Expand Down
Loading

0 comments on commit 0285993

Please sign in to comment.