制作PL / SQL代码并生成PL / SQL文档(pldoc),类似于JavaDoc

在团队内部,您需要制定自己的标准和规则,而文书工作是团队合作的主要规则之一。

好吧,走吧...

链接到pldoc工具本身

通过参考,所有内容都很好地阐述了如何工作和生成文档,但是为了简化起见,我将提供示例和脚本。

安装(解压缩档案)并在根目录中创建run.bat

rmdir /s /q "%TOMCAT_HOME%/Tomcat 7.0/webapps/plsqldoc" call ..\pldoc.bat -verbose -doctitle 'Api shema' -d '%TOMCAT_HOME%/Tomcat 7.0/webapps/plsqldoc' -url jdbc:oracle:thin:@host:port:SID -user API_DOC -password API_DOC -sql SCAPI.%%%%,API.%%%%,SALE.%%%%,BILLING_API.%%%%,BATCH.%%%%, pause 

其中:

  • -d'%TOMCAT_HOME%/ Tomcat 7.0 / webapps / plsqldoc'-将在其中生成文档的文件夹;
  • -url jdbc:oracle:thin:@host:port:SID数据jdbc:oracle:thin:@host:port:SID数据库服务器;
  • -sql API。%%%% T %%%%,SALE.A %%%%,BILLING_API。%%%%
    API。%%%% T %%%%-获取所有包含字母T的API模式对象;
    SALE.A %%%%-采取SALE方案中所有以字母T开头的对象;
    BILLING_API。%%%%-取得BILLING_API模式的所有对象;

根据下面描述的设计pl / sql代码的规则,我们开始并获得完成的文档。

设计实例


登记规则
登记规则

对于包装

 create or replace package EXAMPLE is -------------------------------------------------------------------------- -- ELEMENT PREFIX SUFFIX EXAMPLE DESCRIPTION -------------------------------------------------------------------------- -- variable v_ # v_club# All variables have to start with "v_" ends with "#" in lowercase -- in parameter in_ # in_club# All in parameters have to start with "in_" ends with "#" in lowercase -- out parameter out_ # out_club# All out parameters have to start with "out_" ends with "#" in lowercase -- in/out parameter io_ # io_club# All in/out parameters have to start with "io_" ends with "#" in lowercase -- cursor c_ # c_data# All cursors have to start with "c_" ends with "#" in lowercase -- record rec # rec_date# All records have to start with "rec_" ends with "#" in lowercase -- type t_ # t_data# All types have to start with "t_" ends with "#" in lowercase -- exception e_ # e_frod# All exceptions have to start with "e_" ends with "#" in lowercase /** *    (PL/SQL package) * @author Prigozhiy * @version 1 (29.09.2013) * @headcom */ /*    EMS */ v_esbusername varchar2(20) ; /** ,    * @author Prigozhiy * @version 2 (29.05.2013) * @param in_text#    * @param out_text#    */ procedure pr_output_text ( in_text# in varchar2, out_text# out varchar2 ); /** ,    * @author Prigozhiy * @version 1 (21.05.2013) * @param in_text#    * @return    * @deprecated <a href="EXAMPLE.html#FN_OUTPUT_TEXT_V1(VARCHAR2)">FN_OUTPUT_TEXT_V1</a> * @throws PROGRAM_ERROR ORA-06501   PL/SQL * @see #FN_OUTPUT_TEXT_V1(VARCHAR2) */ function fn_output_text ( in_text# in varchar2 ) return varchar2; /** ,    * @author Prigozhiy * @version 1 (21.05.2013) * @param in_text#    * @return    * @see (<a href="http://%20documentation/html/CONTRACT_RATEPLAN_HISTORY.READcms_cmd.html">CONTRACT_RATEPLAN_HISTORY.READ</a>) * @see (<a href="http://jira.main.by/browse/BSCSOA-87">BSCSOA-87</a>) */ function fn_output_text_v1 ( in_text# in varchar2 ) return varchar2; end EXAMPLE; create or replace package body EXAMPLE is /* Revisions: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 28.05.2013 Prigozhiy Created this procedure 2.0 29.05.2013 Prigozhiy http://jira.main.by/browse/ONEC-49 */ procedure pr_output_text ( in_text# in varchar2, out_text# out varchar2 ) is begin out_text# := upper(in_text#); end; /* Revisions: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 29.05.2013 Prigozhiy Created this procedure */ function fn_output_text ( in_text# in varchar2 ) return varchar2 is out_text# varchar2(100); begin out_text# := substr(upper(in_text#),1,100); return out_text#; end; function fn_output_text_v1 ( in_text# in varchar2 ) return varchar2 is out_text# varchar2(100); begin out_text# := substr(upper(in_text#),1,100); return out_text#; end; end EXAMPLE; 

有关功能和程序

我要求您注意名称功能或过程之后立即开始的对接说明:

 create or replace function get_change_rp_current_month /** ... 

 create or replace function get_change_rp_current_month /**      * @author Prigozhiy * @version 1 (30.05.2013) * @param in_coid id  * @return 0-  , 1-    * @see (<a href="http://documentation/html/CONTRACT_RATEPLAN_HISTORY.READcms_cmd.html">contract.GET_HISTORY_LAST_rateplan_date</a>) * @see (<a href="http://jira.main.by/browse/BSCSOA-87">BSCSOA-87</a>) */ ( in_coid in number ) RETURN number is v_date date; BEGIN /* Revisions: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 30.05.2013 Prigozhiy Created this procedure */ v_date := contract.GET_HISTORY_LAST_rateplan_date(co_id => in_coid); if TRUNC(sysdate, 'month')> v_date then return 0; else return 1; end if; end; 

如果使用PL / SQL Developer来帮助


一种格式格式化

创建pl_sql_beautifief_rules.br sl。 内容:

 Version=1 RightMargin=80 Indent=2 UseTabCharacter=FALSE TabCharacterSize=2 AlignDeclarationGroups=TRUE AlignAssignmentGroups=TRUE KeywordCase=2 IdentifierCase=2 UseSpecialCase=FALSE ItemList.Format=1 ItemList.Align=TRUE ItemList.CommaAfter=TRUE ItemList.AtLeftMargin=FALSE EmptyLines=1 ThenOnNewLine=FALSE LoopOnNewLine=FALSE DML.LeftAlignKeywords=FALSE DML.LeftAlignItems=FALSE DML.OnOneLineIfPossible=FALSE DML.WhereSplitAndOr=TRUE DML.WhereAndOrAfterExpression=FALSE DML.WhereAndOrUnderWhere=TRUE DML.JoinSplitBeforeOn=TRUE DML.InsertItemList.Format=1 DML.InsertItemList.Align=FALSE DML.InsertItemList.CommaAfter=TRUE DML.InsertItemList.AtLeftMargin=FALSE DML.SelectItemList.Format=2 DML.SelectItemList.Align=TRUE DML.SelectItemList.CommaAfter=TRUE DML.SelectItemList.AtLeftMargin=FALSE DML.UpdateItemList.Format=2 DML.UpdateItemList.Align=TRUE DML.UpdateItemList.CommaAfter=TRUE DML.UpdateItemList.AtLeftMargin=FALSE ParameterDeclarationList.Format=1 ParameterDeclarationList.Align=TRUE ParameterDeclarationList.CommaAfter=TRUE ParameterDeclarationList.AtLeftMargin=TRUE RecordFieldList.Format=1 RecordFieldList.Align=TRUE RecordFieldList.CommaAfter=TRUE RecordFieldList.AtLeftMargin=FALSE SplitAndOr=FALSE AndOrAfterExpression=FALSE [SpecialCase] 

然后打开PL / SQL Developer->工具-首选项菜单,然后打开PL / SQL beautifief选项卡,然后打开rules文件并指定文件pl_sql_beautifief_rules.br并确认更改。

现在,我们选择编写的pl / sql代码,并通过单击菜单Edit-> PL / SQL beautifief将其格式化为一种样式。

使用模板

“模板”窗口(在“列表”窗口附近),然后单击鼠标左键“新建模板”。

 /** [Description] * @author [Username = $OSUSER] * @version [Version=1.0] ([Date = $DATE])[+Depricated=" * @deprecated "][Depricated][+Param 1=" * @param "][Param 1][+Param 2=" * @param "][Param 2][+Param 3=" * @param "][Param 3][+Param 4=" * @param "][Param 4][+Param 5=" * @param "][Param 5][+Return=" * @return "][Return][+See=" * @see "][See] */ 

Source: https://habr.com/ru/post/zh-CN442980/


All Articles