CN114637532A - Method for automatically obtaining comments and generating interface document according to fields - Google Patents

Method for automatically obtaining comments and generating interface document according to fields Download PDF

Info

Publication number
CN114637532A
CN114637532A CN202210254956.9A CN202210254956A CN114637532A CN 114637532 A CN114637532 A CN 114637532A CN 202210254956 A CN202210254956 A CN 202210254956A CN 114637532 A CN114637532 A CN 114637532A
Authority
CN
China
Prior art keywords
field
interface document
interface
fields
chain
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210254956.9A
Other languages
Chinese (zh)
Inventor
吕火生
孔令超
何健进
陈啟铭
黄世志
邓维滔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Foshan Zhongtaolian Supply Chain Service Co Ltd
Tibet Zhongtaolian Supply Chain Service Co Ltd
Original Assignee
Foshan Zhongtaolian Supply Chain Service Co Ltd
Tibet Zhongtaolian Supply Chain Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Foshan Zhongtaolian Supply Chain Service Co Ltd, Tibet Zhongtaolian Supply Chain Service Co Ltd filed Critical Foshan Zhongtaolian Supply Chain Service Co Ltd
Priority to CN202210254956.9A priority Critical patent/CN114637532A/en
Publication of CN114637532A publication Critical patent/CN114637532A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

A method for automatically generating an interface document according to a field acquisition comment comprises the following steps: the method comprises the following steps: adding a comment for describing a field of a class source file of Java to the field; step two: according to fields of class source files of Java, a builder design mode is used, and according to naming rules of field names, a chain calling method which is the same as the field names is generated; step three: calling a chain method which is the same as the field name according to the field required by the interface document to define the interface document; step four: and acquiring a field corresponding to the class source file according to the return value after the chain method is called, and acquiring a comment corresponding to the field to generate a field of the interface document. The method solves the problem of repeatedly defining the meaning of the interface field so as to reduce the maintenance cost of the interface document, adopts a chain calling method, supports the characteristic of checking during compiling, finds the problem during code compiling in advance, avoids the problem caused by spelling errors, and improves the coding efficiency under the prompt of developing an auxiliary tool ide.

Description

Method for automatically obtaining comments and generating interface document according to fields
Technical Field
The invention relates to the technical field of interface document processing, in particular to a method for automatically acquiring comments according to fields to generate an interface document.
Background
In the process of developing Java, a code structured parsing technique of a Java source code file is often used to parse a Java text file into a structured data structure according to the syntactic characteristics of Java.
In an interface document, when operations such as adding, deleting, modifying and checking are carried out on a table under different scenes, the fields for modifying the table are different, and the interfaces corresponding to the different operations executed on the same table need to repeatedly define request parameters of the interface, so that the same work needs to be continuously repeated; meanwhile, when the field meaning of the table changes, all the referenced places need to be updated synchronously, which causes higher post-maintenance cost.
Disclosure of Invention
The invention aims to provide a method for automatically acquiring comments to generate an interface document according to fields, which aims to solve the problem of repeatedly defining the meaning of the interface fields so as to reduce the maintenance cost of the interface document.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for automatically obtaining comments according to fields to generate an interface document comprises the following steps:
the method comprises the following steps: adding a comment for describing a field of a class source file of Java to the field;
step two: according to fields of class source files of Java, a builder design mode is used, and according to naming rules of field names, a chain calling method which is the same as the field names is generated;
step three: calling a chain method which is the same as the field name according to the field required by the interface document to define the interface document;
step four: and acquiring a field corresponding to the class source file according to the return value after the chain method is called, and acquiring a comment corresponding to the field to generate a field of the interface document.
Preferably, in the third step, according to the fields required by the interface document, a chained method identical to the field name is called to define the interface document, including:
and on the method corresponding to each interface, using the annotated parameters to define an implementation class of the interface document, wherein the implementation class comprises a first method and a second method, the first method defines fields of interface request parameters, and the second method defines fields of interface response parameters.
A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, carries out the steps of any of the above-mentioned methods.
The beneficial effect that this application's technical scheme produced:
1. the comments of variables below class on the java source code are directly used as the comments of the fields of the interface document, so that the repeated comments of the same field are avoided, the problem of repeatedly defining the meaning of the interface field is solved, and the maintenance cost of the interface document is reduced;
2. according to the variables below class, a set of method codes which are the same as the variable names and support chain calling are automatically generated, the chain method is directly called to declare fields when an interface document is defined to check during compiling, the chain calling method supports the check during compiling, problems can be found during code compiling in advance, the problems caused by misspelling are avoided, and meanwhile, the chain calling method improves the coding efficiency under the prompt of developing auxiliary tools.
Drawings
FIG. 1 is a flow diagram of a method for automatically generating an interface document from field captured annotations, in accordance with an embodiment of the present invention.
Detailed Description
The technical scheme of the invention is further explained by the specific implementation mode in combination with the attached drawings.
In an interface document, when operations such as adding, deleting, modifying and checking are carried out on a table under different scenes, the fields for modifying the table are different, and the interfaces corresponding to the different operations executed on the same table need to repeatedly define request parameters of the interface, so that the same work needs to be continuously repeated; meanwhile, when the field meaning of the table changes, all the referenced places need to be updated synchronously, which causes higher post-maintenance cost. And since the field definitions of the interface document can only be plain string text, compile-time checks cannot be made. In order to solve the above problem, the present application proposes a method for automatically generating an interface document according to a field obtained comment, as shown in fig. 1, including the following steps:
the method comprises the following steps: adding a comment for describing a field of a class source file of Java to the field;
step two: according to fields of class source files of Java, a builder design mode is used, and according to naming rules of field names, a chain calling method which is the same as the field names is generated;
step three: calling a chain method which is the same as the field name according to the field required by the interface document to define the interface document;
step four: and acquiring a field corresponding to the class source file according to the return value after the chain method is called, and acquiring a comment corresponding to the field to generate a field of the interface document.
Preferably, in the third step, according to the fields required by the interface document, a chained method identical to the field name is called to define the interface document, including:
and on the method corresponding to each interface, using the annotated parameters to define an implementation class of the interface document, wherein the implementation class comprises a first method and a second method, the first method defines fields of interface request parameters, and the second method defines fields of interface response parameters.
In this embodiment, for example, an Order table Order corresponds to a code entity ordererity, and 3 columns are arranged on the surface of the Order table and respectively correspond to 3 fields of the code entity ordererity: price, quantity, and amount. There are two interfaces, and the functions implemented by the two interfaces are respectively: based on the above method, when defining the documents of the interface a and the interface B, only the implementation classes of the two documents of the interface a and the interface B need to be implemented, the field names of the parameters are collected in the method for defining the request parameters, and then the comments beginning with "/" above the corresponding field in the code entity orderenty and ending with "/" are resolved according to the field names to be used as descriptions of the fields in the interface document.
In this embodiment, the process of collecting the field names of the parameters is the process of calling the chain methods corresponding to the fields with the same name, each chain method is called, the field names corresponding to the corresponding entities are returned in the form of character strings, and a set of field names, that is, all the fields required by the interface, is formed by calling a series of chain methods.
Further, a chain method defines a field of an interface document, and may be understood as a method having the same name as the field, for example, as for the above-mentioned example, three methods may be defined, namely, the names of the method is print (), quality (), and amount (), and then each method returns a corresponding character string: "print", "qualification" and "around", the calling method using the chain method name is to use the verification mechanism of the compiler to check the spelling problem of the method when defining the field many times, improve the correctness, and at the same time, improve the writing efficiency of the code in the auxiliary input support of the development tool ide. The character string is returned because text characters are needed to be associated with the field names of the entities, corresponding fields are found, and then comments above the fields acquired after the java source file is analyzed are found to be used as field descriptions of the interface document.
A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, carries out the steps of any of the above-mentioned methods.
The technical principle of the present invention is described above in connection with specific embodiments. The description is made for the purpose of illustrating the principles of the invention and should not be construed in any way as limiting the scope of the invention. Based on the explanations herein, those skilled in the art will be able to conceive of other embodiments of the present invention without inventive effort, which would fall within the scope of the present invention.

Claims (3)

1. A method for automatically obtaining comments and generating interface documents according to fields is characterized by comprising the following steps:
the method comprises the following steps: adding a comment for describing a field of a class source file of Java to the field;
step two: according to fields of class source files of Java, a builder design mode is used, and according to naming rules of field names, a chain calling method which is the same as the field names is generated;
step three: calling a chain method which is the same as the field name according to the field required by the interface document to define the interface document;
step four: and acquiring a field corresponding to the class source file according to the return value after the chain method is called, and acquiring a comment corresponding to the field to generate a field of the interface document.
2. The method for automatically generating an interface document according to the comment obtained by the field as claimed in claim 1, wherein:
in the third step, according to the fields required by the interface document, a chained method identical to the field name is called to define the interface document, which includes:
and on the method corresponding to each interface, using the annotated parameters to define an implementation class of the interface document, wherein the implementation class comprises a first method and a second method, the first method defines fields of interface request parameters, and the second method defines fields of interface response parameters.
3. A computer-readable storage medium storing a computer program, the computer program characterized in that:
the computer program when being executed by a processor realizes the steps of the method as set forth in any of the claims 1-2.
CN202210254956.9A 2022-03-15 2022-03-15 Method for automatically obtaining comments and generating interface document according to fields Pending CN114637532A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210254956.9A CN114637532A (en) 2022-03-15 2022-03-15 Method for automatically obtaining comments and generating interface document according to fields

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210254956.9A CN114637532A (en) 2022-03-15 2022-03-15 Method for automatically obtaining comments and generating interface document according to fields

Publications (1)

Publication Number Publication Date
CN114637532A true CN114637532A (en) 2022-06-17

Family

ID=81946861

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210254956.9A Pending CN114637532A (en) 2022-03-15 2022-03-15 Method for automatically obtaining comments and generating interface document according to fields

Country Status (1)

Country Link
CN (1) CN114637532A (en)

Similar Documents

Publication Publication Date Title
US7437374B2 (en) Efficient XML schema validation of XML fragments using annotated automaton encoding
US9710243B2 (en) Parser that uses a reflection technique to build a program semantic tree
US7853936B2 (en) Compilation of nested regular expressions
US20070050704A1 (en) XML compiler that will generate an application specific XML parser
CA2500422A1 (en) Annotated automaton encoding of xml schema for high performance schema validation
Meduna Elements of compiler design
US11042467B2 (en) Automated searching and identification of software patches
Sellink et al. Development, assessment, and reengineering of language descriptions
CN112379917B (en) Browser compatibility improving method, device, equipment and storage medium
CN111367893A (en) Method and device for database version iteration
EP3974964A1 (en) Automated generation of software patches
CN113934786A (en) Implementation method for constructing unified ETL
CN112199626A (en) Dynamic form generation method based on DSL layout engine
CN109947711B (en) Automatic multi-language file management method in IOS project development process
CN114637532A (en) Method for automatically obtaining comments and generating interface document according to fields
Wielemaker et al. Why It's Nice to be Quoted: Quasiquoting for Prolog
CN113239016B (en) Database design assistance apparatus and method
CN113971044A (en) Component document generation method, device, equipment and readable storage medium
CN115390936A (en) Unified verification method, device, equipment and storage medium
CN114546381A (en) Front-end page code file generation method and device, electronic equipment and storage medium
US11556455B2 (en) Automated identification of posts related to software patches
CN114385167A (en) Front-end page generation method, device, equipment and medium
CN112948419A (en) Query statement processing method and device
CN112631567A (en) Method and device for generating database operation file
CN108733353B (en) Interface construction method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination