Interface document generation method and system, storage medium and electronic device

By establishing a file tree and abstract syntax tree during the interface documentation generation process and dynamically updating the interface documentation, the problems of low efficiency and high error rate in interface documentation generation are solved, achieving efficient and accurate interface documentation management.

CN116136837BActive Publication Date: 2025-10-21WUHAN ANTIY MOBILE SECURITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111372669.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-10-21
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

Existing technologies often result in inefficient interface documentation generation, are prone to errors, and are difficult to maintain, leading to reduced development efficiency.

Method used

By retrieving files from the controller folder, a file tree is built, parsed into an abstract syntax tree, and function nodes are converted into interface documentation. Dynamic updates are achieved by using a subprocess to monitor code changes.

Benefits of technology

It improves the accuracy and efficiency of API documentation generation, reduces the error rate, supports real-time synchronous updates, and reduces the pressure on developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116136837B_ABST
    Figure CN116136837B_ABST
Patent Text Reader

Abstract

The application provides an interface document generation method and system, a storage medium and an electronic device, and relates to the technical field of computers. The method comprises the following steps: obtaining a plurality of files in a controller folder, and recursively processing the plurality of files to obtain a file tree; converting the plurality of files respectively to obtain a first character stream corresponding to each file, and parsing the first character stream into an abstract syntax tree, wherein the abstract syntax tree comprises a plurality of function nodes in each file; traversing the abstract syntax tree, converting the plurality of function nodes respectively to obtain a second character stream corresponding to each function node; and converting the second character stream into a corresponding interface document, and mounting the interface document into the file tree. The technical scheme realizes interface document generation through the principles of compilation, abstract syntax trees and document generation tools, can eliminate the error rate during interface document generation, and improves the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an interface document generation method and system, a computer-readable storage medium, and an electronic device. Background Art

[0002] In project development scenarios, front-end and back-end developers need to communicate through interface documentation, which also facilitates developers to review and maintain projects. Therefore, convenient and efficient generation of standardized interface documentation is of great significance to project development.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention

[0004] The purpose of the present disclosure is to provide an interface document generation method and system, a computer-readable storage medium and an electronic device, which can improve the efficiency of interface document generation at least to a certain extent.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.

[0006] According to the first aspect of the present disclosure, a method for generating an interface document is provided, which includes: obtaining multiple files in a controller folder, and recursively performing the multiple files to obtain a file tree; converting the multiple files respectively to obtain a first character stream corresponding to each file, and parsing the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file; traversing the abstract syntax tree, converting the multiple function nodes respectively to obtain a second character stream corresponding to each function node; converting the second character stream into a corresponding interface document, and mounting the interface document into the file tree.

[0007] In one embodiment of the present disclosure, before obtaining the multiple files in the controller folder, the method further includes: creating a child process; recursively performing the multiple files to obtain a file tree, including: judging whether the controller folder includes files through the child process; if the controller folder includes files, mounting the object node corresponding to the file to the file tree, wherein the name of the object node is the same as the file name; if the controller folder does not include files, mounting an empty object node in the file tree.

[0008] In one embodiment of the present disclosure, after the above-mentioned sub-process is created, the above-mentioned method includes: monitoring multiple files in the above-mentioned controller folder through the above-mentioned sub-process to monitor changes in application code in the above-mentioned files within a preset time; when the above-mentioned application code changes, obtaining multiple files in the above-mentioned controller folder, and recursively performing the above-mentioned multiple files to regenerate the above-mentioned file tree.

[0009] In one embodiment of the present disclosure, after the above-mentioned sub-process is created, the above-mentioned method further includes: monitoring the application through the above-mentioned sub-process to monitor the changes of the hash value corresponding to the above-mentioned controller folder within the above-mentioned preset time; when the above-mentioned hash value changes, obtaining multiple files in the above-mentioned controller folder, and recursively performing the above-mentioned multiple files to regenerate the above-mentioned file tree.

[0010] In one embodiment of the present disclosure, after the above-mentioned sub-process is created, the above-mentioned method further includes: creating a document display service in the above-mentioned sub-process, displaying the above-mentioned document tree through the above-mentioned document display service; and displaying the above-mentioned interface document by clicking the above-mentioned object node.

[0011] In one embodiment of the present disclosure, the above-mentioned conversion of the second character stream into the corresponding interface document includes: creating a first file, wherein the file name of the above-mentioned first file is determined according to the name of each of the above-mentioned function nodes and the file name of the file where each of the above-mentioned function nodes is located; writing the above-mentioned second character stream into the above-mentioned first file; and converting the above-mentioned first file into the above-mentioned interface document through a document generator.

[0012] In one embodiment of the present disclosure, the above-mentioned interface document includes the name of each of the above-mentioned function nodes; the above-mentioned mounting of the above-mentioned interface document to the above-mentioned file tree includes: obtaining the file name of the file where each of the above-mentioned function nodes in the above-mentioned first file is located according to the name of each of the above-mentioned function nodes in the above-mentioned interface document; traversing the above-mentioned file tree, and mounting the above-mentioned interface document to the child node of the corresponding object node in the file tree according to the file name of the file where each of the above-mentioned function nodes is located.

[0013] According to the second aspect of the present disclosure, an interface document generation system is provided, which includes: a recursive module, which is used to obtain multiple files in a controller folder and recursively perform the multiple files to obtain a file tree; a first conversion module, which is used to convert the multiple files respectively to obtain a first character stream corresponding to each file, and parse the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file; a second conversion module, which is used to traverse the abstract syntax tree and convert the multiple function nodes respectively to obtain a second character stream corresponding to each function node; and a mounting module, which is used to convert the second character stream into a corresponding interface document and mount the interface document into the file tree.

[0014] According to the third aspect of the present disclosure, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the interface document generation method of the first aspect or the second aspect when executing the computer program.

[0015] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the interface document generation method of the first aspect or the second aspect is implemented.

[0016] The interface document generation method and system, computer-readable storage medium, and electronic device provided by the embodiments of the present disclosure have the following technical effects:

[0017] In the interface document generation process provided by the embodiment of the present disclosure, multiple files in the controller folder are obtained, and the multiple files are recursively processed to obtain a file tree; the multiple files are converted separately to obtain a first character stream corresponding to each file, and the first character stream is parsed into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file; the abstract syntax tree is traversed, and the multiple function nodes are converted separately to obtain a second character stream corresponding to each function node; the second character stream is converted into a corresponding interface document, and the interface document is mounted in the file tree. This technical solution establishes a tree-like document structure through the above-mentioned file tree and abstract syntax tree, which can be used to open the corresponding interface file and the interface contained in the file, and can reduce the error rate when generating the interface document, thereby improving the efficiency of interface document generation.

[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.

[0020] Figure 1 A flowchart of a method for generating an interface document provided by an embodiment of the present disclosure is schematically shown;

[0021] Figure 2 A flowchart of converting a character stream into a document provided by another embodiment of the present disclosure is schematically shown;

[0022] Figure 3 A flowchart of converting a character stream into a document provided by another embodiment of the present disclosure is schematically shown;

[0023] Figure 4 A schematic diagram showing a tree-like document structure;

[0024] Figure 5 The following schematically shows a structural diagram of an interface document generation system provided by an embodiment of the present disclosure;

[0025] Figure 6 A block diagram of an electronic device provided by an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0026] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.

[0027] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

[0028] In the description of the present disclosure, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance. For those skilled in the art, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances. In addition, in the description of the present disclosure, unless otherwise specified, "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship.

[0029] In related technologies, dynamically generating standardized documentation requires first introducing a documentation generation tool. Then, you need to write corresponding comments for each interface that needs to be documented. The documentation generation tool can then read the comments and generate the documentation. The documentation includes all the comments, allowing users to better understand the functionality of the corresponding code. Therefore, interface documentation plays a crucial role in project development.

[0030] However, interface documentation generated based on comments is not entirely reliable. For example, after writing the corresponding interface code, developers may forget to modify the comments, or the comments may contain incorrect text. In these cases, the generated interface documentation may cause users to misunderstand the code's functions, leading to incorrect operations and significantly reducing programmer development efficiency. Furthermore, in related technologies, interface documentation generation can suffer from issues such as difficulty in extraction, confusion, and omissions, resulting in low interface documentation generation efficiency.

[0031] In order to overcome the above technical problems, the embodiments of this specification provide a method and system for generating an interface document, as well as a computer-readable storage medium and an electronic device for implementing the above method.

[0032] Below, each step of the interface document generation method in this example implementation will be described in more detail with reference to the accompanying drawings and embodiments.

[0033] in, Figure 1 The flowchart of the method for generating an interface document according to an exemplary embodiment of the present disclosure is schematically shown.

[0034] S101, obtaining multiple files in a controller folder and recursively performing searches on the multiple files to obtain a file tree;

[0035] S102, converting the multiple files separately to obtain a first character stream corresponding to each file, and parsing the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file;

[0036] S103, traversing the abstract syntax tree, converting multiple function nodes respectively, and obtaining a second character stream corresponding to each function node;

[0037] S104: Convert the second character stream into a corresponding interface document, and mount the interface document into a file tree.

[0038] Figure 1The interface document generation process provided by the illustrated embodiment does not require additional annotations to generate interface documents. Specifically, this technical solution establishes a tree-like document structure through the aforementioned file tree and abstract syntax tree. This tree-like document structure can be used to open the corresponding interface file and the interface contained in the file, thereby reducing the error rate during interface document generation and improving the efficiency of interface document generation.

[0039] For example, the interface document generation method provided by the present disclosure is applied to nodejs (an open source cross-platform operating environment that can run JavaScript on the server side), and the interface document can also be displayed in a tree structure. Figure 1 The specific implementation of each step included in the embodiment is described in detail:

[0040] In S101 , multiple files in a controller folder are acquired, and the multiple files are recursively searched to obtain a file tree.

[0041] In an exemplary embodiment, after an application is created in nodejs, all controller files for which documents need to be generated in a controller folder are obtained, and then a file tree is generated based on the obtained multiple files.

[0042] In an exemplary embodiment, while creating an application, a child process is created to determine whether there are files under the controller folder during the process of recursively performing recursion on multiple files and generating a file tree. Exemplarily, the child process obtains the corresponding character stream every second and compares it, and obtains all controller files of the interface documents to be generated in the nodejs application. Exemplarily, there are multiple levels of directories under a general controller folder, which may be controller files or controller folders. During recursion, if a file exists in a certain level of directory, the object node corresponding to the file is mounted in the file tree, and the name of the object node is the same as the file name of the file. If a folder exists in the directory, it continues to determine whether there are files under the folder until the file is found. If there are no files or folders in the directory, an empty object node is mounted in the file tree to reserve a position for the directory in the file tree. Thus, by monitoring the controller folder and the files therein through the child process, a file tree can be recursively generated.

[0043] In an exemplary embodiment, the subprocess also monitors the application. Within a preset time, the subprocess monitors changes in the hash value corresponding to the controller folder. If the hash value changes, the subprocess retrieves the files in the controller folder and recursively rebuilds the file tree.

[0044] In an exemplary embodiment, the subprocess also monitors files in the controller folder. Within a preset timeframe, the subprocess monitors changes to the application code in the files. If the application code changes, the subprocess retrieves the files in the controller folder and recursively regenerates the file tree.

[0045] By monitoring the application and controller files through subroutines, the interface documents can be updated synchronously in real time when the developer modifies the code, realizing dynamic generation of interface documents and improving development efficiency.

[0046] In S102 , the multiple files are converted respectively to obtain a first character stream corresponding to each file, and the first character stream is parsed into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file.

[0047] In an exemplary embodiment, after finding the file in the controller folder, the JS (Javascript, a standard scripting language for the Internet) file or the TS (Typescript, a source code file) file in the file is converted into a first character stream. The first character stream is then parsed into an abstract syntax tree through the compilation principle. There are different interface functions in the file, so the generated abstract syntax tree also includes function nodes (method nodes) corresponding to multiple interface functions. The abstract syntax tree also includes some blank nodes, and blank nodes are generated for parts of the file where there are no characters (such as blank lines).

[0048] In S103 , the abstract syntax tree is traversed, and multiple function nodes are converted respectively to obtain a second character stream corresponding to each function node.

[0049] In an exemplary embodiment, the abstract syntax tree of the file is then processed: the abstract syntax tree is recursively traversed, the entire abstract syntax tree is deeply traversed, a converted string form code is constructed, and each function node (method node) in the abstract syntax tree is converted into a second character stream.

[0050] In S104 , the second character stream is converted into a corresponding interface document, and the interface document is mounted into a file tree.

[0051] In an exemplary embodiment, this is a specific implementation of "converting the second character stream into a corresponding interface document" in S104. Figure 2 The flowchart of converting a character stream into a document provided by an embodiment of the present disclosure is schematically shown. Figure 2 , the embodiment shown in the figure includes:

[0052] S201, creating a first file, wherein the file name of the first file is determined according to the name of each function node and the file name of each function node. And, S202, writing a second character stream into the first file.

[0053] In an exemplary embodiment, after traversing the above-mentioned abstract syntax tree, a file named "filename_functionname / methodname (fileName_functionName)" (i.e., the above-mentioned first file) can also be created. Furthermore, the second character stream corresponding to each function node is written into the corresponding first file. Among them, "filename" is the name of the file where the function node is located, and "functionname" is the name of the interface function corresponding to the function node. Naming in this way can facilitate the subsequent mounting operation.

[0054] In S203, the first file is converted into an interface document by a document generator.

[0055] In an exemplary embodiment, after obtaining the first file, denodoc (Automatic Documentation Generator for Deno) is used to generate a JSON document (JavaScript Object Notation, a lightweight text data exchange format), i.e., the aforementioned interface document. The interface document includes the interface function name, input parameters (variable parameters required for the interface function request) and their types, and output parameters (output parameters, the interface function's return parameters) and their types, clearly showing the contents of the interface document.

[0056] In an exemplary embodiment, this is a specific implementation of “mounting the interface document into the file tree” in S104 . Figure 3 The flowchart of converting a character stream into a document provided by an embodiment of the present disclosure is schematically shown. Figure 3 , the embodiment shown in the figure includes:

[0057] S301: Based on the name of each function node in the interface document, obtain the file name of the file where each function node is located in the first file. And, S302: traverse the file tree and, based on the file name of the file where each function node is located, mount the interface document to the child node of the corresponding object node in the file tree.

[0058] In an exemplary embodiment, after obtaining the interface document, it is necessary to mount the interface document under the corresponding object node in the file tree. The function node name (interface function name) in the interface document can be used to obtain the first file where the function node is located. Based on the "file name" in this first file, the file name of the file where the function node is located can be obtained.

[0059] In an exemplary embodiment, after obtaining the file name of the file where the function node is located, the name of the corresponding object node can be obtained. Next, the file tree can be traversed to mount the interface document to the child node under the corresponding object node. Exemplarily, for the JSON document generated in the S203 embodiment, the corresponding file name is obtained through the method name, and then the file tree is traversed to mount the JSON document under the node corresponding to the file name. In this way, the mounting of the document corresponding to one interface function in a file is completed. After traversing all controller files and mounting the corresponding documents, the generation of all interface documents in an application can be completed.

[0060] In an exemplary embodiment, the generated file tree can also be displayed. Specifically, a document display service can be created in the above sub-process. Figure 4 The diagram of the tree document structure is shown in the figure. The bottom child node is the interface document generated above, such as Figure 4 Interface documents 1 to 7 are shown. Click the object node where the interface document is located to view the document content. The parent node of the interface document is the file where it is located, such as Figure 4 The parent nodes of sub-files 1 to 4 are the folders where they are located. Figure 4 Folder 1 and Folder 2 are shown. The parent node of Folder 1 and Folder 2 is the overall controller folder. Figure 4 The tree-like document structure shown is for illustration only. The final display effect can be expanded and beautified according to actual needs and is not limited here.

[0061] This embodiment provides a solution for dynamically generating interface documentation using the Deno document generator for Node.js backend services. This method analyzes Node.js applications, uses a child process to monitor the application, generates a file tree from folders and files, converts the code in the files into character streams, and generates an abstract syntax tree using compiler principles. Furthermore, each method node and function node in the abstract syntax tree is translated into character streams, and then standardized documentation is generated using the Deno document generator.

[0062] The interface document generation method provided in the embodiments of this specification is applicable to all application services developed using Node.js. It does not have issues with missing documents or incomplete content, and it does not generate document errors. It can reduce the pressure on programmers and improve development efficiency. In addition, the interface document generation method provided by the present disclosure is highly scalable. Users can customize their own interface document products based on the generated file tree and apply them to various application scenarios. For example, a browser document plug-in can be developed to implement the function of real-time document viewing; an editor document plug-in can also be developed to implement intelligent prompts for code; or a real-time document viewing application can be developed.

[0063] The following are embodiments of the apparatus disclosed herein, which can be used to implement the method embodiments disclosed herein. For details not disclosed in the apparatus embodiments disclosed herein, please refer to the method embodiments disclosed herein.

[0064] in, Figure 5 A structural diagram of an interface document generation system according to an exemplary embodiment of the present disclosure is shown.

[0065] The interface document generation system 500 in the embodiment of the present disclosure includes: a recursive module 501, a first conversion module 502, a second conversion module 503, and a mounting module 504, wherein:

[0066] The recursive module 501 is used to obtain multiple files in the controller folder and recursively perform recursion on the multiple files to obtain a file tree;

[0067] A first conversion module 502 is configured to convert the plurality of files respectively to obtain a first character stream corresponding to each file, and compile the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes a plurality of function nodes in each file;

[0068] The second conversion module 503 is configured to: traverse the abstract syntax tree, convert multiple function nodes respectively, and obtain a second character stream corresponding to each function node;

[0069] The mounting module 504 is used to convert the second character stream into a corresponding interface document and mount the interface document into the file tree.

[0070] It should be noted that the interface document generation device provided in the above embodiment only uses the division of the above functional modules as an example when executing the interface document generation method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the interface document generation system provided in the above embodiment and the interface document generation method embodiment belong to the same concept. Therefore, for details not disclosed in the embodiment of the device disclosed herein, please refer to the embodiment of the interface document generation method disclosed herein, which will not be repeated here.

[0071] The serial numbers of the above-mentioned embodiments of the present disclosure are for description only and do not represent the advantages or disadvantages of the embodiments.

[0072] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the aforementioned methods. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a microdrive, a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.

[0073] An embodiment of the present disclosure further provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the method of any of the above embodiments are implemented.

[0074] Figure 6 Schematically shows a structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. Figure 6 As shown, the electronic device 600 includes a processor 601 and a memory 602 .

[0075] In the embodiment of the present disclosure, the processor 601 is the control center of the computer system, which can be the processor of a physical machine or the processor of a virtual machine. The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state.

[0076] In the embodiment of the present disclosure, the processor 601 is specifically configured to:

[0077] Obtain multiple files in the controller folder, and recursively perform the above multiple files to obtain a file tree; convert the above multiple files separately to obtain a first character stream corresponding to each file, and parse the above first character stream into an abstract syntax tree, wherein the above abstract syntax tree includes multiple function nodes in each of the above files; traverse the above abstract syntax tree, convert the above multiple function nodes separately to obtain a second character stream corresponding to each function node; convert the above second character stream into a corresponding interface document, and mount the above interface document into the above file tree.

[0078] Furthermore, in one embodiment of the present disclosure, before obtaining the multiple files in the controller folder, it also includes: creating a child process; recursively performing the multiple files to obtain a file tree, including: judging whether the controller folder includes files through the child process; if the controller folder includes files, mounting the object node corresponding to the file to the file tree, wherein the name of the object node is the same as the file name; if the controller folder does not include files, mounting an empty object node in the file tree.

[0079] Optionally, after the above-mentioned sub-process is created, it includes: monitoring multiple files in the above-mentioned controller folder through the above-mentioned sub-process to monitor changes in the application code in the above-mentioned files within a preset time; when the above-mentioned application code changes, obtaining multiple files in the above-mentioned controller folder, and recursively performing the above-mentioned multiple files to regenerate the above-mentioned file tree.

[0080] Optionally, after the above-mentioned creation of the sub-process, it also includes: monitoring the application through the above-mentioned sub-process to monitor the changes in the hash value corresponding to the above-mentioned controller folder within the above-mentioned preset time; when the above-mentioned hash value changes, obtaining multiple files in the above-mentioned controller folder, and recursively performing the above-mentioned multiple files to regenerate the above-mentioned file tree.

[0081] Optionally, after the above-mentioned creation of the sub-process, the method further includes: creating a document display service in the above-mentioned sub-process, and displaying the above-mentioned document tree through the above-mentioned document display service; and displaying the above-mentioned interface document by clicking the above-mentioned object node.

[0082] Optionally, the above-mentioned conversion of the second character stream into the corresponding interface document includes: creating a first file, wherein the file name of the above-mentioned first file is determined according to the name of each of the above-mentioned function nodes and the file name of the file where each of the above-mentioned function nodes is located; writing the above-mentioned second character stream into the above-mentioned first file; and converting the above-mentioned first file into the above-mentioned interface document through a document generator.

[0083] Optionally, the above-mentioned interface document includes the name of each of the above-mentioned function nodes; the above-mentioned mounting of the above-mentioned interface document to the above-mentioned file tree includes: obtaining the file name of the file where each of the above-mentioned function nodes in the above-mentioned first file is located according to the name of each of the above-mentioned function nodes in the above-mentioned interface document; traversing the above-mentioned file tree, and mounting the above-mentioned interface document to the child node of the corresponding object node in the file tree according to the file name of the file where each of the above-mentioned function nodes is located.

[0084] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments of the present disclosure, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction, which is used to be executed by the processor 601 to implement the method in the embodiment of the present disclosure.

[0085] In some embodiments, the electronic device 600 further includes a peripheral device interface 603 and at least one peripheral device. The processor 601, memory 602, and peripheral device interface 603 may be connected via a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 603 via a bus, signal lines, or circuit boards. Specifically, the peripheral device includes at least one of a display screen 604, a camera 605, and an audio circuit 606.

[0086] The peripheral device interface 603 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 601 and the memory 602. In some embodiments of the present disclosure, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments of the present disclosure, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 can be implemented on separate chips or circuit boards. This is not specifically limited in the present disclosure.

[0087] The display screen 604 is used to display a user interface (UI). This UI can include graphics, text, icons, videos, or any combination thereof. When the display screen 604 is a touch screen display, it can also capture touch signals on or above the surface of the display screen 604. These touch signals can be input as control signals to the processor 601 for processing. In this case, the display screen 604 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments of the present disclosure, there can be one display screen 604, provided on the front panel of the electronic device 600. In other embodiments of the present disclosure, there can be at least two display screens 604, provided on different surfaces of the electronic device 600 or in a foldable design. In still other embodiments of the present disclosure, the display screen 604 can be a flexible display, provided on a curved or foldable surface of the electronic device 600. Furthermore, the display screen 604 can be configured as a non-rectangular, irregular shape, also known as a special-shaped screen. The display screen 604 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0088] The camera 605 is used to capture images or videos. Optionally, the camera 605 includes a front camera and a rear camera. Typically, the front camera is provided on the front panel of the electronic device, and the rear camera is provided on the back of the electronic device. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments of the present disclosure, the camera 605 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0089] Audio circuit 606 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals for input to processor 601 for processing. For the purpose of stereo sound collection or noise reduction, multiple microphones may be provided, respectively, at different locations within electronic device 600. The microphone may also be an array microphone or an omnidirectional microphone.

[0090] Power supply 607 is used to power the various components of electronic device 600. Power supply 607 can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When power supply 607 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0091] The electronic device structure block diagram shown in the embodiment of the present disclosure does not constitute a limitation on the electronic device 600. The electronic device 600 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.

[0092] In the present disclosure, the terms "first", "second", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or order; the term "plurality" refers to two or more, unless otherwise expressly defined. The terms "installed", "connected", "connected", "fixed", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; "connected" can be a direct connection or an indirect connection through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in the present disclosure can be understood according to the specific circumstances.

[0093] In the description of the present disclosure, it is necessary to understand that the terms "upper" and "lower" etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or unit referred to must have a specific direction, be constructed and operated in a specific orientation. Therefore, they cannot be understood as limitations on the present disclosure.

[0094] The above descriptions are merely specific embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any modifications or substitutions that can be readily conceived by a person skilled in the art within the technical scope disclosed herein are intended to be covered by the scope of protection of the present disclosure. Therefore, equivalent modifications made according to the claims of the present disclosure are still within the scope of protection of the present disclosure.

Claims

1. A method for generating an interface document, characterized in that: include: Obtain multiple files in the controller folder and recursively perform operations on the multiple files to obtain a file tree; Converting the multiple files respectively to obtain a first character stream corresponding to each file, and parsing the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes multiple function nodes in each file; Traversing the abstract syntax tree, converting the multiple function nodes respectively, and obtaining a second character stream corresponding to each function node; Convert the second character stream into a corresponding interface document, and mount the interface document into the file tree.

2. The interface document generation method according to claim 1, characterized in that: Before obtaining the plurality of files in the controller folder, the method further includes: creating a child process; The recursive operation on the multiple files to obtain a file tree includes: Determine, by the sub-process, whether the controller folder includes a file; If the controller folder includes a file, then mounting the object node corresponding to the file into the file tree, wherein the name of the object node is the same as the file name; If the controller folder does not include any files, an empty object node is mounted in the file tree.

3. The interface document generation method according to claim 2, characterized in that: After creating the child process, the method further includes: Monitoring multiple files in the controller folder through the subprocess to monitor changes in application code in the files within a preset time; In the case that the application code is changed, multiple files in the controller folder are obtained and recursively processed to regenerate the file tree.

4. The interface document generation method according to claim 2 or 3, characterized in that: After creating the child process, the method further includes: Monitoring the application program through the subprocess to monitor changes in the hash value corresponding to the controller folder within a preset time; In the case where the hash value changes, multiple files in the controller folder are obtained and recursively searched to regenerate the file tree.

5. The interface document generation method according to claim 4, characterized in that: After creating the child process, the method further includes: Creating a document display service in the subprocess, and displaying the document tree through the document display service; The interface document is displayed by clicking the object node.

6. The interface document generation method according to claim 5, characterized in that: The converting the second character stream into a corresponding interface document includes: Creating a first file, wherein the file name of the first file is determined according to the name of each function node and the file name of the file where each function node is located; Writing the second character stream into the first file; The first file is converted into the interface document by a document generator.

7. The interface document generation method according to claim 6, characterized in that: The interface document includes the name of each function node; Mounting the interface document into the file tree includes: Obtaining, according to the name of each function node in the interface document, the file name of the file where each function node in the first file is located; The file tree is traversed, and according to the file name of the file where each function node is located, the interface document is mounted to the child node of the corresponding object node in the file tree.

8. An interface document generation system, characterized in that: include: The recursive module is used to: obtain multiple files in the controller folder and recursively perform recursion on the multiple files to obtain a file tree; a first conversion module, configured to convert the plurality of files respectively to obtain a first character stream corresponding to each file, and parse the first character stream into an abstract syntax tree, wherein the abstract syntax tree includes a plurality of function nodes in each file; A second conversion module is configured to: traverse the abstract syntax tree, convert the multiple function nodes respectively, and obtain a second character stream corresponding to each function node; The mounting module is used to convert the second character stream into a corresponding interface document and mount the interface document into the file tree.

9. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the interface document generation method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the interface document generation method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • An interface document automatic generation method and a terminal device

    CN109375922A

  • Method and device for generating application programming interface document and electronic equipment

    CN112667274A