⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uoptionswizard.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 4 页
字号:
        assert(False);
      end;
    end
   else
    assert(False);
  end; //if Generator is TCommentDoc
end;

{Called when the page should no longer be shown, but not when the wizard is
 ended.
~param NewPage the page that will be shown instead }
procedure TCommentPositionsWizard.HidePage(NewPage: TWizardPage);
var       Generator              :TCommentDoc; //the currently chosen generator
begin
 //generator uses comments?
 if TGeneratorManager(Data).TheGenerator is TCommentDoc then
  begin
   //get the current generator
   Generator := TCommentDoc(TGeneratorManager(Data).TheGenerator);

   //comments of files can be searched after the first statement
   if assigned(FCheckBoxFileCommentAfterFirstStatement) then
    SetBooleanOption(Generator.Extractor.GetOptions, //set option
                     'FileCommentAfterFirstStatement',
                     FCheckBoxFileCommentAfterFirstStatement.Checked);
   //comments of identifiers can be searched at their forward-declaration?
   if assigned(FCheckBoxIdentifierCommentAtForward) then
    SetBooleanOption(Generator.Extractor.GetOptions, //set the option
                     'GetForwardComments',
                     FCheckBoxIdentifierCommentAtForward.Checked);
   //comments of identifiers can also be searched at the other delcaration?
   if assigned(FCheckBoxIdentifierCommentFallBack) then
    SetBooleanOption(Generator.Extractor.GetOptions, //set the option
                     'FallBackToOtherPositionForComment',
                     FCheckBoxIdentifierCommentFallBack.Checked);
  end; //if Generator is TCommentDoc

 FCheckBoxFileCommentAfterFirstStatement := nil;  //controls will be removed
 FCheckBoxIdentifierCommentAtForward := nil;
 FCheckBoxIdentifierCommentFallBack := nil;

 inherited HidePage(NewPage);                  //hide the page
end;

















   { * * *  ***  * * *  ***   TCommentFilterWizard   ***  * * *  ***  * * *  }

{Creates the page and initializes its attributes.
~param Form         the form to show the page of the wizard on
~param Parent       the parent to show the components of the page on
~param Data         custom data for the wizard
~param PreviousPage the previous page of this page (to go back to) }
constructor TCommentFilterWizard.Create(Form: TForm; Parent: TWinControl;
                                        Data: TObject;
                                        PreviousPage: TWizardPage);
begin
 inherited Create(Form, Parent, Data, PreviousPage);  //create the object

 FCaption := 'What comments to use?';
 FHelpContext := 31103;
end;

{Called when the state of the checkbox about using only comments with leading
 stars is changed.
~param Sender the sender of the event, ~[link FCheckBoxOnlyStaredComments] }
procedure TCommentFilterWizard.CheckBoxOnlyStaredComments(Sender: TObject);
begin
 assert(assigned(FCheckBoxOnlyStaredComments));
 //if only comments with leading stars should be used
 if assigned(FCheckBoxRemoveStars) and FCheckBoxOnlyStaredComments.Checked then
  //by default also remove all leading stars
  FCheckBoxRemoveStars.Checked := FCheckBoxOnlyStaredComments.Checked;
end;

{Returns the next page to be shown.
~result the next page to be shown }
function TCommentFilterWizard.GetNextPage: TWizardPage;
begin
 //current generator uses comments?
 if TGeneratorManager(Data).TheGenerator is TCommentDoc then
  begin                                     //create the next page
   Result := TParseCommentWizard.Create(Form, Parent, Data, Self);
   Result.SuperPage := SuperPage;
  end
 else
  Result := nil;                            //end this sub-thread
end;

{Called when the page should be shown.
~param PreviousPage the previously shown page or nil }
procedure TCommentFilterWizard.ShowPage(PreviousPage: TWizardPage);
var       Generator           :TCommentDoc;    //the currently chosen generator
          Value               :Boolean;        //value of options
begin
 inherited ShowPage(PreviousPage);             //start the page

 //generator uses comments?
 if TGeneratorManager(Data).TheGenerator is TCommentDoc then
  begin
   ShowText('With some of the options you can define what parts of the comments to use and also only to use comments that are specially tagged.' + LineDelimiter +
            'The most powerful way is using regular expressions. In this wizard only a simpler version to check for the JavaDoc-like stars "*" is provided. ' +
            'Please check the list of options of the generator to use regular expressions.');
   inc(FNewComponentTop, 10);

   //get the current generator
   Generator := TCommentDoc(TGeneratorManager(Data).TheGenerator);

   //can be set to use only comments with a trailing star?
   if GetBooleanOption(Generator.Extractor.GetOptions,
                       'UseOnlyStaredComments', Value) then
    begin
     //show option to select whether only they should be used
     ShowText('You can filter the comments to be used. In JavaDoc only comments with an additional star "*" are considered (this changed in Javadoc 1.4). You can filter all comments not beginning with an additional star.');
     FCheckBoxOnlyStaredComments :=
                       AddCheckBox('Use only comments with a preceding &star?',
                                   Value, CheckBoxOnlyStaredComments);
     inc(FNewComponentTop, 10);
    end
   else
    assert(False);

   //can remove leading (and trailing) stars from the comments?
   if GetBooleanOption(Generator.Extractor.GetOptions,
                       'RemoveLeadingStars', Value) then
    begin
     //show option to select whether the stars should be removed
     ShowText('If you use additional stars in your comments, to tag them for inclusion in the documentation or for your better readability, you can remove them with this option. '+
              'All stars at the beginning and the end of the comment and also stars at the beginning of each line are removed.');
     FCheckBoxRemoveStars := AddCheckBox('&Remove leading and trailing stars?',
                                         Value);
    end
   else
    assert(False);
  end; //if Generator is TCommentDoc
end;

{Called when the page should no longer be shown, but not when the wizard is
 ended.
~param NewPage the page that will be shown instead }
procedure TCommentFilterWizard.HidePage(NewPage: TWizardPage);
var       Generator           :TCommentDoc;    //the currently chosen generator
begin
 //generator uses comments?
 if TGeneratorManager(Data).TheGenerator is TCommentDoc then
  begin
   //get the current generator
   Generator := TCommentDoc(TGeneratorManager(Data).TheGenerator);

   //only comments with a leading star should be used, all others ignored?
   if assigned(FCheckBoxOnlyStaredComments) then
    SetBooleanOption(Generator.Extractor.GetOptions, 'UseOnlyStaredComments',
                     FCheckBoxOnlyStaredComments.Checked); //set the option

   //leading and trailing stars should automatically be removed?                  
   if assigned(FCheckBoxRemoveStars) then
    begin
     SetBooleanOption(Generator.Extractor.GetOptions, 'RemoveLeadingStars',
                      FCheckBoxRemoveStars.Checked);        //set the option
     SetBooleanOption(Generator.Extractor.GetOptions, 'RemoveTrailingStars',
                      FCheckBoxRemoveStars.Checked);        //set the option
    end;
  end;

 FCheckBoxOnlyStaredComments := nil;           //controls will be deleted
 FCheckBoxRemoveStars := nil;

 inherited HidePage(NewPage);                  //hide the page
end;





















   { * * *  ***  * * *  ***   TParseCommentWizard   ***  * * *  ***  * * *  }


{Creates the page and initializes its attributes.
~param Form         the form to show the page of the wizard on
~param Parent       the parent to show the components of the page on
~param Data         custom data for the wizard
~param PreviousPage the previous page of this page (to go back to) }
constructor TParseCommentWizard.Create(Form: TForm; Parent: TWinControl;
                                       Data: TObject;
                                       PreviousPage: TWizardPage);
begin
 inherited Create(Form, Parent, Data, PreviousPage);  //create the object

 FCaption := 'Parse comments?';
 FHelpContext := 31104;
end;


{$IFNDEF LINUX}

{Called when the button to show the documentation is clicked.
~param Sender the sender of the event, the button }
procedure TParseCommentWizard.ButtonShowDocumentation(Sender: TObject);
begin
 ShowDocumentation(FHelpContext, 'manual.html');  //show the documentation
end;

{$ENDIF}


{Called when the state of the checkbox is changed.
~param Sender the sender of the event, ~[link FCheckBoxParseComments] }
procedure TParseCommentWizard.CheckBoxParseCommentsClicked(Sender: TObject);
begin
 //comment should be parsed?
 if (TGeneratorManager(Data).TheGenerator is TCommentDoc) and
    assigned(FCheckBoxParseComments) and FCheckBoxParseComments.Checked then
  Include(FButtonsEnabled, wbNext)                 //there is a next page
 else
  Exclude(FButtonsEnabled, wbNext);                //end of options
 RequestButtonUpdate;
end;


{Returns the next page to be shown.
~result the next page to be shown }
function TParseCommentWizard.GetNextPage: TWizardPage;
begin
 //current generator uses comments and comments are parsed?
 if assigned(FCheckBoxParseComments) and FCheckBoxParseComments.Checked and
    (TGeneratorManager(Data).TheGenerator is TCommentDoc) then
  begin                                     //create the next page
   Result := TCommentOptionsWizard.Create(Form, Parent, Data, Self);
   Result.SuperPage := SuperPage;
  end
 else
  Result := nil;                            //end this sub-thread
end;

{Called when the page should be shown.
~param PreviousPage the previously shown page or nil }
procedure TParseCommentWizard.ShowPage(PreviousPage: TWizardPage);
var       Generator          :TCommentDoc;     //the currently chosen generator
          Value              :Boolean;
begin
 inherited ShowPage(PreviousPage);             //start the page

 //coming from the succeeding page?
 if assigned(FNextPage) and (PreviousPage = FNextPage) then
  begin
   FNextPage := nil;                             //no succeeding page again
   PreviousPage.Free;                            //free the succeeding page
  end;

 //generator uses comments?
 if TGeneratorManager(Data).TheGenerator is TCommentDoc then
  begin
   ShowText('The comments can include special sections and commands to document the identifiers and files better and create links etc..' + LineDelimiter +
            'Sections and commands are marked with a leading special character, by default it is "~", but it can be changed. ' +
            'Comments using these sections and commands should be much more useful and readable.');
{$IFNDEF LINUX}
   AddButton('Show &Documentation', ButtonShowDocumentation);
{$ENDIF}
   inc(FNewComponentTop, 10);

   //get the current generator
   Generator := TCommentDoc(TGeneratorManager(Data).TheGenerator);

   //comments can also be used without parsing as simple texts?
   if GetBooleanOption(Generator.Evaluator.GetOptions,
                       'DontParseComments', Value) or
      GetBooleanOption(Generator.Extractor.GetOptions,
                       'DoNotSectionize', Value) then
    begin
     //show option to select whether the comments should be parsed
     ShowText('If the source code is not commented in this way, you can disable the parsing of the comments here, so you don''t get error messages or strange formatted documentation. ' +
              'The comment will used as-is without any formatings or any special sections.');
     FCheckBoxParseComments := AddCheckBox('&Parse Comments?', not Value,
                                           CheckBoxParseCommentsClicked);
    end
   else
    assert(False);


   //can keep the line breaks in the comments?
   if GetBooleanOption(Generator.GetOptions, 'KeepLineBreaksInComments',
                       Value) then
    begin
     //show option to select whether to keep the line breaks
     ShowText('Text will normally float around, line breaks in the source code will not be kept. This can be changed here.');
     FCheckBoxKeepLineBreaks := AddCheckBox('&Keep line breaks in Comments?',
                                            Value);
     inc(FNewComponentTop, 10);
    end
   else
    assert(False);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -