Interface document generation method and device, storage medium and electronic equipment
By identifying and parsing the target field information in the interface code file and generating interface documents, the high cost problem of relying on manual annotations in the existing technology is solved, and the interface documents are automatically generated and development costs are reduced.
Patent Information
- Application Number
- CN202411883814.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-06-10
AI Technical Summary
In the prior art, when generating interface documents corresponding to interface code files, developers rely on the developer to add additional interface document annotations in the interface code files in advance, resulting in high labor costs and lack of effective solutions.
By obtaining the interface code file (excluding interface document comments), the target field in the interface code file is identified, and the corresponding target information is determined based on the identified target field, and the interface document corresponding to the interface code file is generated.
It realizes that interface documents can be generated without relying on interface document annotations, reducing the workload of developers and reducing labor costs.
Smart Images

Figure CN120122985A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of fintech or other fields. Specifically, it relates to a method, device, storage medium and electronic device for generating interface documents. Background Art
[0002] With more and more applications launched by various institutions (such as financial institutions, etc.), the development work of applications has become in full swing. The front-end and back-end docking of applications is an important part of the development work. The back-end developers providing the interface description documents for the front-end developers can greatly improve the development efficiency and make the front-end development work proceed smoothly.
[0003] Currently, the method for generating back-end interface documents is usually in the form of configuration, adding interface document annotations or methods for adding input parameter attributes at the place where the code is written, adding automated markings in a redundant coding form, and then the interface document generation tool performs annotation parsing and document generation according to the configuration file on the defined section. Taking the typical interface document generation tool Swagger as an example, its internal principle is as described above, and in terms of usage, it is mainly divided into three steps. The first is to add dependencies, the second is to add a Swagger component configuration class, and the third is to supplement document data information in the interface class (for example, adding annotations before the method input parameters, and the annotation content includes redundant field names and field meanings). This method requires developers to add interface document comments in the interface code file in advance, resulting in a high labor cost problem.
[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] The main purpose of the present application is to provide a method, device, storage medium and electronic device for generating interface documents, so as to solve the problem in the related technology that when generating the interface document corresponding to the interface code file, it depends on developers to add interface document comments in the interface code file in advance and generate the interface document by identifying the interface document comments, resulting in a high labor cost problem.
[0006] To achieve the above object, according to one aspect of the present application, a method for generating an interface document is provided. The method includes: obtaining an interface code file, wherein the interface code file does not include interface document comments, and the interface document comments refer to comments used for an interface document generation tool to identify; identifying target fields in the interface code file, and determining target information corresponding to the target fields based on each identified target field, wherein the target fields include fields required during the execution of the code in the interface code file and code comment fields in the interface code file, and the target information refers to information required for the interface document to be generated; generating an interface document corresponding to the interface code file according to the target information corresponding to each target field.
[0007] Further, the method for generating an interface document further includes: determining a target class from the interface code file, wherein the target class is the class for which the target fields are to be identified; for each interface method of the target class, identifying target fields from the interface method, and determining target information corresponding to the target fields based on the target fields; determining the next target class from the interface code file, and repeating to determine the target information corresponding to the target fields in the next target class until there are no target classes in the interface code file, thereby obtaining the target information corresponding to each target field in the interface code file.
[0008] Further, the target fields include a first type of field and a second type of field. The first type of field is used to map a request to the interface method to which the first type of field belongs, and the second type of field is used to map a request to the class to which the second type of field belongs. Wherein, the method for generating an interface document further includes: traversing downward from the target starting position corresponding to the interface method until a first type of field is found; determining the target information corresponding to the first type of field according to the path value associated with the first type of field in the interface method and the path value associated with the second type of field of the class to which the interface method belongs.
[0009] Further, the target fields include a third type of field and a fourth type of field. The third type of field is the field in the code comment used to identify the method description of the interface method, and the fourth type of field is the field in the code comment used to identify the parameter description of the parameters in the interface method. Wherein, the method for generating an interface document further includes: traversing upward starting from the first type of field, and when the first field is found, traversing downward starting from the first field, where the first field refers to the field characterizing the beginning of the code comment of the interface method; if a third type of field is found during the downward traversal, determining the target information corresponding to the third type of field according to the method description information associated with the third type of field in the interface method; if a fourth type of field is found during the downward traversal, determining the target information corresponding to the fourth type of field according to the parameter description information associated with the fourth type of field in the interface method; if a first type of field is found during the downward traversal, it is determined that the traversal of the interface method is completed.
[0010] Further, the method for generating an interface document further includes: after traversing upward starting from the first type of field, when a second field is found, it is determined that the traversal of the interface method is completed, where the second field is a field used to represent the boundary between different interface methods.
[0011] Further, the method for generating an interface document further includes: after determining a target class from the interface code file, determining the class starting position of the target class; traversing upward starting from the class starting position until a second type of field is found; and determining the second type of field found as the second type of field associated with the target class.
[0012] Further, the method for generating an interface document further includes: after determining the target information corresponding to the target field based on the target field, determining the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method; and generating the interface document corresponding to the interface code file according to the target information corresponding to each target field, including: generating the interface document based on the interface information associated with each class in the interface code file.
[0013] To achieve the above object, according to another aspect of the present application, there is provided a device for generating an interface document. The device includes: an acquisition module, configured to acquire an interface code file, where the interface code file does not include interface document comments, and the interface document comments are comments used for an interface document generation tool to identify; a first determination module, configured to identify target fields in the interface code file and determine the target information corresponding to the target field based on each identified target field, where the target fields include fields required during the execution of the code in the interface code file and code comment fields in the interface code file, and the target information is information required for the interface document to be generated; and a generation module, configured to generate the interface document corresponding to the interface code file according to the target information corresponding to each target field.
[0014] Further, the first determination module further includes: a first determination sub-module, configured to determine a target class from the interface code file, where the target class is the class for which the target field is to be identified; a second determination sub-module, configured to, for each interface method of the target class, identify the target field from the interface method and determine the target information corresponding to the target field based on the target field; and a processing sub-module, configured to determine the next target class from the interface code file and repeatedly execute to determine the target information corresponding to the target field in the next target class until there is no target class in the interface code file, so as to obtain the target information corresponding to each target field in the interface code file.
[0015] Further, the target fields include first - type fields and second - type fields. The first - type fields are used to map requests to the interface methods to which the first - type fields belong, and the second - type fields are used to map requests to the classes to which the second - type fields belong. Among them, the second determination sub - module further includes: a processing unit for traversing downward from the target starting position corresponding to the interface method until the first - type field is found; a determination unit for determining the target information corresponding to the first - type field according to the path value associated with the first - type field in the interface method and the path value associated with the second - type field of the class to which the interface method belongs.
[0016] Further, the target fields include third - type fields and fourth - type fields. The third - type fields are the fields in the code comments used to identify the method descriptions of the interface methods, and the fourth - type fields are the fields in the code comments used to identify the parameter descriptions of the parameters in the interface methods. Among them, the interface document generation device further includes: a first processing module for traversing upward starting from the first - type field, and when the first field is found, traversing downward starting from the first field, where the first field is the field indicating the beginning of the code comment characterizing the interface method; a second determination module for, if the third - type field is found during the downward traversal, determining the target information corresponding to the third - type field according to the method description information associated with the third - type field in the interface method; a third determination module for, if the fourth - type field is found during the downward traversal, determining the target information corresponding to the fourth - type field according to the parameter description information associated with the fourth - type field in the interface method; a fourth determination module for, if the first - type field is found during the downward traversal, determining that the traversal of the interface method is completed.
[0017] Further, the interface document generation device further includes: a fifth determination module for determining that the traversal of the interface method is completed when the second field is found, where the second field is the field indicating the boundary between different interface methods.
[0018] Further, the interface document generation device further includes: a sixth determination module for determining the class starting position of the target class; a second processing module for traversing upward starting from the class starting position until the second - type field is found; a seventh determination module for determining the found second - type field as the second - type field associated with the target class.
[0019] Further, the interface document generation device further includes: an eighth determination module for determining the interface information corresponding to the interface of the interface method according to the target information of each target field in the interface method; the generation module further includes: a generation sub - module for generating an interface document according to the interface information associated with each class in the interface code file.
[0020] To achieve the above object, according to another aspect of the present application, there is provided a computer-readable storage medium, which includes a stored executable program. When the executable program runs, it controls the device where the computer-readable storage medium is located to execute the above method for generating an interface document.
[0021] To achieve the above object, according to another aspect of the present application, there is provided an electronic device, which includes a memory storing an executable program, and a processor for running the program. When the program runs, it executes the above method for generating an interface document.
[0022] To achieve the above object, according to another aspect of the present application, there is provided a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, the steps of the above method for generating an interface document are implemented.
[0023] In the embodiments of the present application, by identifying target fields in an interface code file and determining target information corresponding to each identified target field based on the identified target fields, the information required for the interface document to be generated is determined according to the original code in the interface code file. By generating an interface document corresponding to the interface code file according to the target information corresponding to each target field, an interface document is generated based on the information determined from the original code, thereby avoiding the dependence on interface document annotations during the process of generating the interface document, effectively reducing the work of developers, and reducing the labor cost.
[0024] It can be seen that in the solution provided by the present application, the purpose of generating an interface document according to the original code in the interface code file is achieved, the technical effect of reducing the labor cost is realized, and the problem of high labor cost in the related art when generating an interface document corresponding to an interface code file, which depends on developers to add interface document annotations in the interface code file in advance and generates the interface document by identifying the interface document annotations, is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings constituting a part of the present application are used to provide a further understanding of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0026] Figure 1 is a hardware structure block diagram of a computer terminal provided according to an embodiment of the present application;
[0027] Figure 2 is a flowchart of a method for generating an interface document provided according to an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of determining target information provided according to an embodiment of the present application;
[0029] Figure 4 is a schematic diagram of a generating device for an interface document provided according to an embodiment of the present application;
[0030] Figure 5 is a structural block diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0033] It should be noted that the method, device, storage medium and electronic device for generating the interface document of the present disclosure can be used in the field of fintech, and can also be used in any field other than the field of fintech. The application field of the method, device, storage medium and electronic device for generating the interface document of the present disclosure is not limited.
[0034] It should be noted that the information collected in the present application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. And the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data and other processing comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse. For example, an interface is set between the present system and relevant users or institutions to provide corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.
[0035] Example 1
[0036] According to the embodiments of the present application, an embodiment of a method for generating an interface document is further provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0037] The method embodiment provided by the first embodiment of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing the method for generating an interface document is shown. As Figure 1 shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (illustrated by 102a, 102b,..., 102n in the figure) (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition to this, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown, or have a different configuration from Figure 1 shown.
[0038] It should be noted that the above one or more processors 102 and / or other data processing circuits are generally referred to as "data processing circuits" in this article. The data processing circuit may be embodied in whole or in part as software, hardware, firmware, or any arbitrary combination thereof. In addition, the data processing circuit may be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit is used for a processor control (such as the selection of a variable resistor terminal path connected to an interface).
[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the interface document generation method in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned interface document generation method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.
[0040] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include the wireless network provided by the communication provider of the computer terminal 10. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0041] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables a user to interact with the user interface of the computer terminal 10 (or mobile device).
[0042] Under the above operating environment, the present application provides the interface document generation method as Figure 2 shown. Figure 2 It is a flowchart of the interface document generation method provided according to the embodiments of the present application.
[0043] Step S201, obtain an interface code file, where the interface code file does not include interface document comments, and the interface document comments refer to comments used for an interface document generation tool to identify.
[0044] Optionally, devices such as electronic devices, application systems, and servers can be used as the execution subject of the present application. In this embodiment, the target processing system is used as the execution subject to execute the interface document generation method.
[0045] Optionally, the target processing system may obtain an interface code file from a target storage area, where a business interface code file exposed to the front end is stored in the target storage area. Optionally, the business content processed by the interface code file varies according to different actual application scenarios. For example, in a financial scenario, the code in the interface code file may be code for counting a user's daily consumption amount. In this embodiment, the business content processed by the interface code file is not specifically limited.
[0046] In some embodiments, the target processing system may use a Python algorithm to scan files under the path of a specified folder (i.e., the target storage area) and scan out all interface code files in this folder. Optionally, the interface code file may be Java code, and optionally, it may also be code of other types.
[0047] In some embodiments, the interface code file includes code comments but does not include interface document comments. Among them, code comments are comments added by back-end developers during code writing for the convenience of future code maintenance. Taking Java as an example, developers usually add comment segments and parameter filling instructions near field attributes and method functions. Such comment formats are generally relatively free and cannot be directly recognized by interface document generation tools; interface document comments are specifically used to describe interface information, such as the path of the interface, request method, parameters, return values, etc. They are additional comments made by back-end developers outside of code comments and usually need to follow specific format specifications, such as the annotation method of Swagger, so that interface document generation tools can automatically recognize them.
[0048] Step S202: Identify target fields in the interface code file and determine target information corresponding to the target fields based on the identified target fields. Among them, the target fields include fields required during the execution of the code in the interface code file and code comment fields in the interface code file, and the target information refers to the information required for the interface document to be generated.
[0049] Optionally, after obtaining the interface code file, the target processing system may identify target fields in the interface code file and determine target information corresponding to the target fields based on the identified target fields. For example, a field list is preset in the target processing system, and the target fields to be identified are recorded in the field list. The target processing system may traverse the interface code file according to the field list to identify target fields from the interface code file.
[0050] In some embodiments, the interface code file includes at least one class, and each class includes at least one interface method.
[0051] In some embodiments, the target fields include a first type of field and a second type of field. The first type of field is used to map a request to an interface method to which the first type of field belongs, and the second type of field is used to map a request to a class to which the second type of field belongs.
[0052] In some embodiments, the target fields further include a third type of field and a fourth type of field. The third type of field is a field in the code comment for identifying the method description of the interface method, and the fourth type of field is a field in the code comment for identifying the parameter description of the parameters in the interface method.
[0053] Optionally, after identifying the target fields, the target processing system may determine the target information corresponding to the target fields based on the target fields. For example, the information associated with the target fields in the class or interface method in the interface code file is determined as the target information corresponding to the target fields.
[0054] For example, when the target field is a first type of field, the target information corresponding to the target field is the path value associated with the first type of field in the interface method; when the target field is a second type of field, the target information corresponding to the target field is the path value associated with the second type of field in the class; when the target field is a third type of field, the target information corresponding to the target field is the method description information associated with the third type of field in the interface method, and when the target field is a fourth type of field, the target information corresponding to the target field is the parameter description information associated with the fourth type of field in the interface method.
[0055] Step S203, generate an interface document corresponding to the interface code file according to the target information corresponding to each target field.
[0056] In some embodiments, the target information determined by the target processing system is stored in the form of a dictionary. The key in the dictionary can be the class name + interface method name, and the value in the dictionary can be the target information. Optionally, the target processing system can use a Python algorithm to convert the dictionary into a json file to obtain the interface document. In some embodiments, after obtaining the json file, the target processing system can use the server-side scripting language PHP (Hypertext Preprocessor) code to read the json file and convert it into a usable document page for presenting the interface document to the user.
[0057] In some embodiments, an interface document in the form of a page is displayed through a Java Web main program. Optionally, a first piece of code can be added to the Java Web main program (usually ending with Application). The first piece of code is used to execute a second piece of code in the Shell manner each time the Java Web main program is restarted (for example, due to project updates, the staff restarts the Java Web main program). The second piece of code is used to execute the above-mentioned method for generating the interface document. Thus, each time the Java Web main program is restarted, the interface document can be regenerated, which facilitates the update of the document.
[0058] In some embodiments, in order to protect sensitive information, a line "@sensitive" can be added to the code comments of the interface code file to mark the third type of fields and the fourth type of fields. Thus, when the target processing system reads "@sensitive", it is prohibited from determining the target information corresponding to the third type of fields and the fourth type of fields marked by this "@sensitive", so as to avoid counting such information into the interface document.
[0059] In some embodiments, the above-mentioned second piece of code and PHP code can be placed in the Java project to achieve local construction. Currently, the related technology generates interface documents by adding dependencies. However, such methods often require additional configurations, thus there are certain potential hazards, such as interface information leakage, project function information leakage, and Trojan attacks contained in the dependencies. In this application, there are only two additional files, one is the Python program code, and the other is the PHP program code for visualization. Such files are local, lightweight, and transparent, without security risks, thus the security of generating interface documents can be improved.
[0060] In the embodiments of this application, by identifying the target fields in the interface code file and determining the target information corresponding to each identified target field, the information required for the interface document to be generated is determined based on the original code in the interface code file. By generating the interface document corresponding to the interface code file according to the target information corresponding to each target field, the interface document is generated based on the information determined from the original code. Thus, the dependence on the interface document comments is avoided during the process of generating the interface document, effectively reducing the work of developers and lowering the labor cost.
[0061] It can be seen that in the solution provided by this application, the purpose of generating an interface document based on the original code in the interface code file is achieved, the technical effect of reducing labor costs is realized, and the problem of high labor costs in the related art when generating an interface document corresponding to the interface code file is solved. In the related art, developers are relied on to add interface document comments in the interface code file in advance, and the interface document is generated by identifying the interface document comments.
[0062] Optionally, in the method for generating an interface document provided in the embodiments of this application, Figure 3 It is a schematic diagram for determining target information provided in the embodiments of this application. As Figure 3 shown, in the process of identifying target fields in the interface code file and determining the target information corresponding to the target fields based on the identified target fields, the following steps are included:
[0063] Step S301, determine a target class from the interface code file, where the target class is the class for which the target fields are to be identified.
[0064] In some embodiments, the interface code file includes at least one class, and each class includes at least one interface method.
[0065] Optionally, after obtaining the interface code file, the target processing system may start from the first line of the interface code file and traverse from top to bottom until the starting position of the first class is found, and determine the class corresponding to the starting position of the first class as the first target class. Optionally, when the target processing system finds the first code line, it may determine that the starting position of the class is found. For example, the first code line may be a code line starting with a first preset character and ending with a second preset character. The first preset character may be "class", and the second preset character may be "{".
[0066] Step S302, for each interface method of the target class, identify target fields from the interface method, and determine the target information corresponding to the target fields based on the target fields.
[0067] Optionally, after finding the first target class, the target processing system can, for each interface method of the target class, identify the target fields from the interface method and determine the target information corresponding to the target fields based on the target fields. For example, starting from the class start position of the target class, traverse downward to find the first interface method in the target class, then identify the target fields from this interface method and determine the target information corresponding to the target fields based on the target fields. After that, traverse the second interface method in the target class, identify the target fields from the second interface method, and determine the target information corresponding to the target fields based on the target fields. Continue to traverse downward in this way until the class end identifier is found to determine that the traversal of the target class is completed. Among them, the class end identifier can be "}".
[0068] Step S303, determine the next target class from the interface code file, and repeat the determination of the target information corresponding to the target fields in the next target class until there is no target class in the interface code file, and obtain the target information corresponding to each target field in the interface code file.
[0069] Optionally, after determining that the traversal of the first target class is completed, the target processing system can determine the next target class from the interface code file. For example, find the second class start position in the interface code file and determine the class corresponding to the second class start position as the second target class. Then, for each interface method of the second target class, identify the target fields from this interface method and determine the target information corresponding to the target fields based on the target fields. Optionally, after the traversal of the second target class is completed, the target processing system can continue to traverse downward until there is no class start position after the last class with identified target fields, and determine that there is no target class in the interface code file. In this case, obtain the target information corresponding to each target field in the interface code file.
[0070] It should be noted that through the above method, the effective traversal of the interface code file is realized in terms of classes and interface methods. On the one hand, it avoids the omission of target fields in the interface code file, which is convenient for improving the accuracy of the generated interface document. On the other hand, it improves the orderliness of the obtained target information, which is convenient for improving the efficiency of generating the interface code file.
[0071] Optionally, in the method for generating an interface document provided in the embodiments of the present application, the target fields include first-type fields and second-type fields. The first-type fields are used to map requests to the interface methods to which the first-type fields belong, and the second-type fields are used to map requests to the classes to which the second-type fields belong. Among them, identifying the target fields from the interface methods and determining the target information corresponding to the target fields based on the target fields includes: traversing downward from the target start position corresponding to the interface method until the first-type fields are found; determining the target information corresponding to the first-type fields according to the path value associated with the first-type fields in the interface method and the path value associated with the second-type fields of the class to which the interface method belongs.
[0072] In some embodiments, when the target class is determined and the first interface method in the target class is to be traversed, the target start position corresponding to the interface method is determined as the target start position corresponding to the interface method. Optionally, the target processing system may traverse downward from the class start position of the target class until the first-type fields are found. For example, the first-type fields are "@RequestMapping" or "@PostMapping" or "@GetMapping" set in the interface method. The "@RequestMapping" in the interface method is used to map all types of HTTP (Hypertext Transfer Protocol) requests to the interface method to which it belongs. The "@PostMapping" is used to map HTTP POST-type requests to the interface method to which it belongs. The "@GetMapping" is used to map HTTP GET-type requests to the interface method to which it belongs. Optionally, after the first-type fields are found, the target processing system may determine the path value in the adjacent parentheses after the first-type fields as the path value associated with the first-type fields in the interface method.
[0073] In some embodiments, when the target class is determined and the non-first interface method in the target class is to be traversed, the first-type fields in the previous interface method corresponding to the interface method to be traversed (also referred to as the current interface method) are determined as the target start position of the interface method to be traversed. Optionally, the target processing system may traverse downward from the first-type fields in the previous interface method until the first-type fields are found. For example, the first-type fields are "@RequestMapping" or "@PostMapping" or "@GetMapping" set in the interface method, so as to determine the path value in the adjacent parentheses after the first-type fields as the path value associated with the first-type fields in the current interface method.
[0074] Optionally, after determining the path value associated with the first type of field in the interface method, the target processing system may determine the target information corresponding to the first type of field based on the path value associated with the first type of field in the interface method and the path value associated with the second type of field of the class to which the interface method belongs.
[0075] Optionally, the second type of field of the class to which the interface method belongs may be found by traversing upward starting from the class starting position of the target class. For example, the second type of field is "@RequestMapping" or "@PostMapping" or "@GetMapping" set outside the interface method in the target class.
[0076] Optionally, for each first type of field, the target processing system may splice the path value associated with the first type of field in the interface method behind the path value associated with the second type of field of the class to which the interface method belongs to form a complete path, and thus determine the complete path as the target information corresponding to the first type of field.
[0077] In some embodiments, the target processing system may store the target information corresponding to the first type of field in a predefined document information dictionary. Optionally, the target information corresponding to the first type of field may be used as the value of the target key in the document information dictionary, and the target key refers to the key corresponding to the interface method to which the first type of field belongs.
[0078] It should be noted that through the above method, the path information of the request to be processed by the interface method is used as the target information, and the accurate determination of the target information is realized, so that the accuracy and content richness of the generated interface document can be effectively improved.
[0079] Optionally, in the method for generating an interface document provided in the embodiments of the present application, the target fields include a third type of field and a fourth type of field. The third type of field is a field used to identify the method description of the interface method in the code comment, and the fourth type of field is a field used to identify the parameter description of the parameters in the interface method in the code comment. After determining the target information corresponding to the first type of field, the method further includes: traversing upward starting from the first type of field, and when the first field is found, traversing downward starting from the first field, where the first field is a field used to represent the beginning of the code comment of the interface method; if the third type of field is found during the downward traversal, determine the target information corresponding to the third type of field according to the method description information associated with the third type of field in the interface method; if the fourth type of field is found during the downward traversal, determine the target information corresponding to the fourth type of field according to the parameter description information associated with the fourth type of field in the interface method; if the first type of field is found during the downward traversal, it is determined that the traversal of the interface method is completed.
[0080] In some embodiments, the first field refers to a field used to characterize the beginning of the code comment of the interface method. For example, the first field can be " / **".
[0081] In some embodiments, the third type of field is a field in the code comment used to identify the method description of the interface method. For example, the third type of field can be "@apiNote", and there may be multiple third type of fields in the interface method. Optionally, the text content adjacent to the third type of field can be determined as the method description information associated with the third type of field in the interface method.
[0082] In some embodiments, the fourth type of field is a field in the code comment used to identify the parameter description of the parameters in the interface method. For example, the fourth type of field can be "@param", and there may be multiple fourth type of fields in the interface method. Optionally, the text content adjacent to the fourth type of field can be determined as the parameter description information associated with the fourth type of field in the interface method.
[0083] For example, assume that the first type of field in the interface method is "@RequestMapping". Then the target processing system can traverse upward starting from "@RequestMapping", and when " / **" is found, it can be regarded as the start of the comment of this interface method, and then traverse downward starting from " / **". If "@apiNote" or "@param" is encountered during the downward traversal, the surrounding method description and parameter description can be extracted respectively to determine the target information. If "@RequestMapping" is encountered during the downward traversal, it is determined that the traversal of this interface method is completed.
[0084] It should be noted that through the above process, the method description and parameter description in the interface method are used as the target information, and the accurate determination of this target information is realized, so that the accuracy and content richness of the generated interface document can be effectively improved.
[0085] Optionally, in the method for generating an interface document provided in the embodiments of the present application, after traversing upward starting from the first type of field, the target processing system can determine that the traversal of the interface method is completed when the second field is found, where the second field refers to a field used to characterize the boundary between different interface methods.
[0086] Optionally, the second field can be understood as a method end identifier, and the second field can be "}". If the second field is found during the upward traversal starting from the first type of field, it is determined that the traversal of this interface method is completed, and it is determined that this interface method is an interface method that does not require document description.
[0087] Since both the aforementioned class end identifier and the above-mentioned second field are "}", optionally, the target processing system can distinguish the class end identifier from the second field according to the code structure. For example, if the content before "}" is a method body (e.g., including return type, method name, and parameter list, etc.), it is determined that the second field is found; if the content before "}" is a class declaration (e.g., including class name and possible inheritance or interface implementation), it is determined that the class identifier end is found. Optionally, the target processing system can also distinguish the class end identifier from the second field according to the indentation level. For example, if the indentation level of "}" is the same as that of the class start "{", it is determined that the class identifier end is found; if the indentation level is more internal, it is determined that the second field is found. Optionally, the target processing system can also distinguish the class end identifier from the second field in other ways.
[0088] It should be noted that through the above method, the accurate determination of whether the interface method traversal is completed is realized, so that the efficiency of generating the interface document can be improved.
[0089] Optionally, in the method for generating an interface document provided in the embodiments of the present application, after determining the target class from the interface code file, the method further includes: determining the class start position of the target class; traversing upward from the class start position until the second type of field is found; determining the second type of field found as the second type of field associated with the target class.
[0090] Optionally, the target processing system can determine that the class start position is found when the first code line is found. For example, the first code line can be a code line starting from a first preset character and ending with a second preset character. The first preset character can be "class", and the second preset character can be "{".
[0091] Optionally, the second type of field is used to map the request to the class to which the second type of field belongs. For example, the second type of field is "@RequestMapping" or "@PostMapping" or "@GetMapping" set outside the interface method in the target class.
[0092] Optionally, after determining the start position of the target class, the target processing system can traverse upward from the class start position until the second type of field is found. If the second type of field is found, the path value in the parentheses adjacent to the second type of field can be determined as the path value associated with the second type of field in the class.
[0093] Optionally, a process of traversing the interface document in an optional embodiment of this embodiment is described. For example, the target processing system first finds the code line starting with "class" and ending with "{" in the interface code file, and then traverses upward from this code line until it finds @RequestMapping, records the associated path value in the document information dictionary, and then traverses downward. If @RequestMapping or @PostMapping or @GetMapping appears, it is considered that the interface definition code segment exposed by Java to the front end is encountered. At this time, read the path value associated with this code segment and splice it behind the path value of the class previously recorded in the document information dictionary to form a complete path. Then, start scanning forward, and regard the first place where " / **" is encountered as the start of the annotation of this interface method. If the text "}" is encountered first when scanning forward, terminate the extraction of this interface method, and regard this interface method as an interface method that does not require documentation. If " / **" is successfully scanned, start scanning downward to find @apiNote and @param. After encountering them, extract the corresponding method description and parameter description until @RequestMapping or @PostMapping or @GetMapping is encountered again, indicating that the traversal of this interface method is completed, and then scan downward to traverse the next interface method. Repeatedly execute the above algorithm to extract the target information of all target fields in the target interface document.
[0094] It should be noted that through the above process, the accurate determination of the second type of fields is realized, so that the target information corresponding to the first type of fields can be determined based on the path value associated with the accurate second type of fields, and further the accuracy of the generated interface document can be improved.
[0095] Optionally, in the interface document generation method provided in the embodiment of the present application, after determining the target information corresponding to the target field based on the target field, the method further includes: determining the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method; generating an interface document corresponding to the interface code file according to the target information corresponding to each target field, including: generating an interface document according to the interface information associated with each class in the interface code file.
[0096] Optionally, after determining the target information corresponding to the target field based on the target field, the target processing system can determine the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method. For example, store the target information of each target field in the interface method in a dictionary. The key in the dictionary can be the class name + interface method name, and the value in the dictionary can be the target information, so as to determine a key-value pair in the dictionary as the interface information of the interface corresponding to an interface method.
[0097] Optionally, after obtaining the interface information of the interfaces corresponding to each interface method, the target processing system can use a Python algorithm to convert a dictionary into a json file, thereby obtaining an interface document.
[0098] In some embodiments, after obtaining the json file, the target processing system can determine the identity information of the target object, and thus determine the display mode of the interface document to be presented to the target object according to the identity information of the target object. For example, if the target object is a front-end personnel, the target processing system can use the server-side scripting language PHP (Hypertext Preprocessor) code to read the json file and convert it into a usable document page to present the interface document to the target object in the form of a web page. If the target object is a project manager or a technical supervisor, the interface document can be converted into a table form and then the table-form interface document can be sent to the target object.
[0099] It should be noted that through the above method, the effective determination of the interface information of each interface is realized, thereby improving the accuracy of the generated interface document.
[0100] Thus, in the solution provided by this application, the purpose of generating an interface document according to the original code in the interface code file is achieved, the technical effect of reducing the labor cost is realized, and the problem of high labor cost in the related art when generating the interface document corresponding to the interface code file, which depends on developers to add interface document comments in the interface code file in advance and generates the interface document by identifying the interface document comments, is solved.
[0101] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0102] Embodiment 2
[0103] The embodiment of this application also provides a device for generating an interface document. It should be noted that the Z device in the embodiment of this application can be used to execute the method for generating an interface document provided by the embodiment of this application. The following introduces the device for generating an interface document provided by the embodiment of this application.
[0104] According to the embodiment of this application, there is also provided a device for implementing the above method for generating an interface document. Figure 4 is a schematic diagram of the device for generating an interface document provided by the embodiment of this application, as Figure 4 shown, the device includes:
[0105] An obtaining module 401 is configured to obtain an interface code file, where the interface code file does not include interface document comments, and the interface document comments refer to comments for an interface document generation tool to identify.
[0106] A first determination module 402 is configured to identify target fields in the interface code file, and determine target information corresponding to the target fields based on the identified target fields, where the target fields include fields required during code execution in the interface code file and code comment fields in the interface code file, and the target information refers to information required for the interface document to be generated.
[0107] A generation module 403 is configured to generate an interface document corresponding to the interface code file according to the target information corresponding to each target field.
[0108] In the embodiment of the present application, by identifying target fields in the interface code file and determining target information corresponding to the target fields based on the identified target fields, it is realized to determine information required for the interface document to be generated according to the original code in the interface code file. By generating an interface document corresponding to the interface code file according to the target information corresponding to each target field, it is realized to generate an interface document based on the information determined from the original code, thereby avoiding dependence on interface document comments during the process of generating the interface document, effectively reducing the work of developers, and reducing labor costs.
[0109] It can be seen that in the solution provided in the present application, the purpose of generating an interface document according to the original code in the interface code file is achieved, the technical effect of reducing labor costs is realized, and the problem of high labor costs in the related art when generating an interface document corresponding to an interface code file, which depends on developers to add interface document comments in the interface code file in advance and generates the interface document by identifying the interface document comments, is solved.
[0110] Optionally, in the interface document generation device provided in the embodiment of the present application, the first determination module further includes: a first determination sub-module, configured to determine a target class from the interface code file, where the target class is a class for which target fields are to be identified; a second determination sub-module, configured to, for each interface method of the target class, identify target fields from the interface method and determine target information corresponding to the target fields based on the target fields; and a processing sub-module, configured to determine the next target class from the interface code file and repeat the determination of target information corresponding to the target fields in the next target class until there is no target class in the interface code file, so as to obtain target information corresponding to each target field in the interface code file.
[0111] Optionally, in the interface document generation device provided in the embodiments of the present application, the target fields include first type fields and second type fields. The first type fields are used to map requests to the interface methods to which the first type fields belong, and the second type fields are used to map requests to the classes to which the second type fields belong. Among them, the second determination sub-module further includes: a processing unit, configured to traverse downward from the target starting position corresponding to the interface method until a first type field is found; a determination unit, configured to determine the target information corresponding to the first type field according to the path value associated with the first type field in the interface method and the path value associated with the second type fields of the class to which the interface method belongs.
[0112] Optionally, in the interface document generation device provided in the embodiments of the present application, the target fields include third type fields and fourth type fields. The third type fields are fields in the code comments used to identify the method descriptions of the interface methods, and the fourth type fields are fields in the code comments used to identify the parameter descriptions of the parameters in the interface methods. Among them, the interface document generation device further includes: a first processing module, configured to traverse upward starting from the first type fields, and when a first field is found, traverse downward starting from the first field, where the first field is a field used to represent the beginning of the code comment of the interface method; a second determination module, configured to, if a third type field is found during the downward traversal, determine the target information corresponding to the third type field according to the method description information associated with the third type field in the interface method; a third determination module, configured to, if a fourth type field is found during the downward traversal, determine the target information corresponding to the fourth type field according to the parameter description information associated with the fourth type field in the interface method; a fourth determination module, configured to, if a first type field is found during the downward traversal, determine that the traversal of the interface method is completed.
[0113] Optionally, in the interface document generation device provided in the embodiments of the present application, the interface document generation device further includes: a fifth determination module, configured to determine that the traversal of the interface method is completed when a second field is found, where the second field is a field used to represent the boundary between different interface methods.
[0114] Optionally, in the interface document generation device provided in the embodiments of the present application, the interface document generation device further includes: a sixth determination module, configured to determine the class starting position of the target class; a second processing module, configured to traverse upward starting from the class starting position until a second type field is found; a seventh determination module, configured to determine the found second type field as the second type field associated with the target class.
[0115] Optionally, in the interface document generation device provided in the embodiments of the present application, the interface document generation device further includes: an eighth determination module, configured to determine the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method; the generation module further includes: a generation sub-module, configured to generate an interface document according to the interface information associated with each class in the interface code file.
[0116] It should be noted here that the above-mentioned acquisition module 401, the first determination module 402, and the generation module 403 correspond to steps S201 to S203 in Embodiment 1. The instances and application scenarios implemented by the three modules and the corresponding steps are the same, but are not limited to the content disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned module or unit may be a hardware component or a software component stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n). The above-mentioned module may also be a part of the device and may run in the computer terminal 10 provided in Embodiment 1.
[0117] Embodiment 3
[0118] Embodiments of the present application may provide an electronic device. Figure 5 It is a structural block diagram of an electronic device according to an embodiment of the present application. As Figure 5 shown, the electronic device may include: one or more ( Figure 5 only one is shown in the figure) processors 1002, a memory 1004, a storage controller, and a peripheral interface. Among them, the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0119] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the above-mentioned methods. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, a flash memory, or other non-volatile solid-state memories. In some instances, the memory may further include a memory remotely provided with respect to the processor, and these remote memories may be connected to the terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an enterprise internal network, a local area network, a mobile communication network, and combinations thereof.
[0120] The processor can call the information and application programs stored in the memory through the transmission device to execute the following steps: obtain an interface code file, where the interface code file does not include interface document comments, and interface document comments refer to comments used for interface document generation tools to identify; identify target fields in the interface code file, and determine the target information corresponding to the target fields based on the identified target fields, where the target fields include fields required for code execution in the interface code file and code comment fields in the interface code file, and the target information refers to the information required for the interface document to be generated; generate an interface document corresponding to the interface code file according to the target information corresponding to each target field.
[0121] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: determine a target class from the interface code file, where the target class is the class for which target fields are to be identified; for each interface method of the target class, identify target fields from the interface method and determine the target information corresponding to the target fields based on the target fields; determine the next target class from the interface code file and repeat the process of determining the target information corresponding to the target fields in the next target class until there are no target classes in the interface code file, so as to obtain the target information corresponding to each target field in the interface code file.
[0122] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: traverse downward from the target starting position corresponding to the interface method until the first type of field is found; determine the target information corresponding to the first type of field based on the path value associated with the first type of field in the interface method and the path value associated with the second type of field of the class to which the interface method belongs.
[0123] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: traverse upward starting from the first type of field, and when the first field is found, traverse downward starting from the first field, where the first field refers to the field indicating the beginning of the code comment of the interface method; if the third type of field is found during the downward traversal, determine the target information corresponding to the third type of field based on the method description information associated with the third type of field in the interface method; if the fourth type of field is found during the downward traversal, determine the target information corresponding to the fourth type of field based on the parameter description information associated with the fourth type of field in the interface method; if the first type of field is found during the downward traversal, it is determined that the traversal of the interface method is completed.
[0124] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: after traversing upward starting from the first type of field, if the second field is found, it is determined that the traversal of the interface method is completed, where the second field is a field used to represent the boundary between different interface methods.
[0125] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: after determining the target class from the interface code file, determine the class start position of the target class; traverse upward starting from the class start position until the second type of field is found; determine the second type of field found as the second type of field associated with the target class.
[0126] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: after determining the target information corresponding to the target field based on the target field, determine the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method; generate the interface document corresponding to the interface code file according to the target information corresponding to each target field, including: generating the interface document based on the interface information associated with each class in the interface code file.
[0127] In the embodiment of the present application, by identifying the target fields in the interface code file and determining the target information corresponding to the target fields based on the identified target fields, the information required for the interface document to be generated is determined according to the original code in the interface code file. By generating the interface document corresponding to the interface code file according to the target information corresponding to each target field, the interface document is generated based on the information determined from the original code, thereby avoiding the dependence on the interface document comments in the process of generating the interface document, effectively reducing the work of developers and reducing the labor cost.
[0128] It can be seen that in the solution provided by the present application, the purpose of generating the interface document according to the original code in the interface code file is achieved, the technical effect of reducing the labor cost is realized, and the problem of high labor cost in the related art when generating the interface document corresponding to the interface code file, which depends on the developers to add interface document comments in the interface code file in advance and generates the interface document by identifying the interface document comments, is solved.
[0129] Those of ordinary skill in the art can understand that Figure 5 The structure shown is only schematic, and the electronic device can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and terminal devices such as Mobile Internet Devices (MID), PAD, etc. Figure 5It does not limit the structure of the above-mentioned electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, a display device, etc.) than those shown in Figure 5 or have a different configuration from that shown in Figure 5 .
[0130] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.
[0131] Embodiment 4
[0132] An embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the above storage medium may be used to store the program code executed by the method for generating the interface document provided in the first embodiment above.
[0133] Optionally, in this embodiment, the above storage medium may be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0134] The present application also provides a computer program product, which is adapted to execute the program of the steps of the method for generating the interface document when executed on a data processing device.
[0135] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0136] In the above embodiments of the present application, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0137] In the several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces, and the indirect coupling or communication connection of the units or modules can be in an electrical or other form.
[0138] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0139] In addition, in each embodiment of the present application, each functional unit can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0140] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs, etc., which can store program codes.
[0141] The above description is only a preferred embodiment of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A method for generating an interface document, characterized in that: include: Obtain an interface code file, wherein the interface code file does not include interface document comments, and the interface document comments refer to comments for identification by an interface document generation tool; Identify the target fields in the interface code file, and determine the target information corresponding to the target field based on each identified target field, wherein the target field includes the fields required for code execution in the interface code file and the code comment fields in the interface code file, and the target information refers to the information required for the interface document to be generated; An interface document corresponding to the interface code file is generated according to the target information corresponding to each target field.
2. The method according to claim 1, characterized in that Identifying the target fields in the interface code file, and determining the target information corresponding to the target fields based on the identified target fields, including: Determine a target class from the interface code file, wherein the target class is a class of a target field to be identified; For each interface method of the target class, identifying the target field from the interface method, and determining target information corresponding to the target field based on the target field; Determine the next target class from the interface code file, and repeatedly determine the target information corresponding to the target field in the next target class until the target class does not exist in the interface code file, and obtain the target information corresponding to each target field in the interface code file.
3. The method according to claim 2, characterized in that The target field includes a first type of field and a second type of field, the first type of field is used to map the request to the interface method to which the first type of field belongs, and the second type of field is used to map the request to the class to which the second type of field belongs, wherein the target field is identified from the interface method, and the target information corresponding to the target field is determined based on the target field, including: Traverse downward from the target starting position corresponding to the interface method until the first type of field is found; The target information corresponding to the first-category fields is determined according to the path value associated with the first-category fields in the interface method and the path value associated with the second-category fields of the class to which the interface method belongs.
4. The method according to claim 3, characterized in that The target field includes a third type of field and a fourth type of field, the third type of field is a field in the code annotation used to identify a method description of an interface method, and the fourth type of field is a field in the code annotation used to identify a parameter description of a parameter in an interface method, wherein after determining the target information corresponding to the first type of field, the method further includes: Traverse upwards starting from the first type of fields, and when a first field is found, traverse downwards starting from the first field, wherein the first field refers to a field used to represent the beginning of a code comment of the interface method; If the third-category field is found during the downward traversal, the target information corresponding to the third-category field is determined according to the method description information associated with the third-category field in the interface method; If the fourth type of field is found in the process of downward traversal, the target information corresponding to the fourth type of field is determined according to the parameter description information associated with the fourth type of field in the interface method; If the first type of field is found during the downward traversal, it is determined that the interface method traversal is completed.
5. The method according to claim 4, characterized in that After traversing upwards starting from the first type of fields, the method further includes: When the second field is found, it is determined that the interface method traversal is completed, wherein the second field refers to a field used to characterize the boundary between different interface methods.
6. The method according to claim 3, characterized in that: After determining the target class from the interface code file, the method further includes: Determine a class starting position of the target class; Traverse upward from the start position of the class until the second class field is found; The found second-category field is determined as the second-category field associated with the target class.
7. The method according to claim 2, characterized in that After determining the target information corresponding to the target field based on the target field, the method further includes: Determine the interface information of the interface corresponding to the interface method according to the target information of each target field in the interface method; Generating an interface document corresponding to the interface code file according to the target information corresponding to each target field, including: The interface document is generated according to the interface information associated with each class in the interface code file.
8. A device for generating an interface document, characterized in that: include: An acquisition module, used for acquiring an interface code file, wherein the interface code file does not include interface document comments, and the interface document comments refer to comments for identification by an interface document generation tool; A first determination module is used to identify the target field in the interface code file, and determine the target information corresponding to the target field based on each identified target field, wherein the target field includes the field required for the code execution in the interface code file and the code comment field in the interface code file, and the target information refers to the information required for the interface document to be generated; A generation module is used to generate an interface document corresponding to the interface code file according to the target information corresponding to each target field.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the method for generating an interface document as described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor is used to run the program, wherein the program, when running, executes the method for generating an interface document as described in any one of claims 1 to 7.
11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method for generating an interface document as described in any one of claims 1 to 7 are implemented.