Creaci贸n de c贸digo PL / SQL y generaci贸n de documentaci贸n PL / SQL (pldoc), similar a JavaDoc

Dentro del equipo, debe desarrollar sus propios est谩ndares y reglas, y el papeleo es una de las principales reglas del trabajo en equipo.

Bueno, vamos ...

Enlace a la herramienta pldoc en s铆 .

Por referencia, todo est谩 bien dise帽ado para trabajar y generar documentaci贸n, pero para facilitarlo, dar茅 ejemplos y scripts.

Instale (descomprima el archivo) y cree run.bat en la ra铆z

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 

donde:

  • -d '% TOMCAT_HOME% / Tomcat 7.0 / webapps / plsqldoc': la carpeta donde se generar谩 la documentaci贸n;
  • -url jdbc:oracle:thin:@host:port:SID servidor de base de datos jdbc:oracle:thin:@host:port:SID donde jdbc:oracle:thin:@host:port:SID los datos;
  • -sql API. %%%% T %%%%, SALE.A %%%%, BILLING_API. %%%%
    API. %%%% T %%%% - toma todos los objetos de esquema API que contienen la letra T;
    SALE.A %%%% - toma todos los objetos del esquema SALE comenzando con la letra T;
    BILLING_API. %%%% - toma todos los objetos del esquema BILLING_API;

Comenzamos y obtenemos la documentaci贸n terminada, de acuerdo con las reglas para dise帽ar el c贸digo pl / sql que se describe a continuaci贸n.

Ejemplo de dise帽o


Reglas para el registro .
Reglas para el registro .

Para paquetes

 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; 

Por funci贸n y procedimiento

Le pido que preste atenci贸n a que la descripci贸n del documento comienza inmediatamente despu茅s de la funci贸n o procedimiento de nombre:

 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; 

Si usa PL / SQL Developer para ayudar


Formateo en un estilo

Cree pl_sql_beautifief_rules.br sl. contenido:

 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] 

Luego abra el men煤 PL / SQL Developer -> Herramientas - Preferencias, luego la pesta帽a de embellecimiento PL / SQL, luego el archivo de reglas y especifique el archivo pl_sql_beautifief_rules.br y confirme los cambios.

Ahora seleccionamos el c贸digo pl / sql escrito y lo formateamos en un estilo haciendo clic en el men煤 Editar -> embellecimiento PL / SQL.

Usar plantillas

La ventana Plantillas (cerca de la ventana Lista de ventanas), luego el bot贸n izquierdo del mouse Nueva plantilla.

 /** [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/442980/


All Articles