CN115934101A - Interface document generation method, device, medium and electronic equipment - Google Patents

Interface document generation method, device, medium and electronic equipment Download PDF

Info

Publication number
CN115934101A
CN115934101A CN202211686476.6A CN202211686476A CN115934101A CN 115934101 A CN115934101 A CN 115934101A CN 202211686476 A CN202211686476 A CN 202211686476A CN 115934101 A CN115934101 A CN 115934101A
Authority
CN
China
Prior art keywords
target
structure tree
main structure
determining
text
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211686476.6A
Other languages
Chinese (zh)
Inventor
孙云洲
程强
万月亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ruian Technology Co Ltd
Original Assignee
Beijing Ruian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ruian Technology Co Ltd filed Critical Beijing Ruian Technology Co Ltd
Priority to CN202211686476.6A priority Critical patent/CN115934101A/en
Publication of CN115934101A publication Critical patent/CN115934101A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the application discloses an interface document generation method, an interface document generation device, an interface document generation medium and electronic equipment. The method comprises the following steps: determining a target code text according to an interface document generation request, and analyzing the target code text to obtain a text analysis result; determining a target main class in the target code text based on the text analysis result, and constructing a main structure tree of the target main class; determining annotation content corresponding to the composition nodes in the main structure tree based on the text analysis result; and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. According to the technical scheme, the interface document is automatically generated, and the generation efficiency of the interface document is improved.

Description

Interface document generation method, device, medium and electronic equipment
Technical Field
The present application relates to the field of computer application technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for generating an interface document.
Background
With the continuous development of computer technology, the performance of software products is more perfect and the functions are more abundant. It can be appreciated that the performance sophistication and function richness of a software product are generally directly related to the complexity and code volume of the software product.
A software product with complete performance and rich functions is usually developed by multiple developers together, different developers usually carry out service docking based on interface documents, and the interface documents are used as data bases of service docking to directly influence the development efficiency of the software product.
In the related art, most interface documents are written and maintained manually by developers, and the interface documents are written manually, which has the problems of low interface document generation efficiency and high generation cost.
Disclosure of Invention
The application provides an interface document generation method, an interface document generation device, a medium and electronic equipment, which can achieve the purposes of improving the automation degree of generating an interface document, improving the generation efficiency of the interface document and reducing the generation cost.
According to a first aspect of the present application, there is provided an interface document generation method, the method including:
determining a target code text according to an interface document generation request, and analyzing the target code text to obtain a text analysis result;
determining a target main class in the target code text based on the text analysis result, and constructing a main structure tree of the target main class;
determining annotation content corresponding to the composition nodes in the main structure tree based on the text analysis result;
and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree.
According to a second aspect of the present application, there is provided an interface document generation apparatus comprising:
the code text analysis module is used for determining a target code text according to the interface document generation request and analyzing the target code text to obtain a text analysis result;
the main structure tree building module is used for determining a target main class in the target code text based on the text analysis result and building a main structure tree of the target main class;
the annotation content determining module is used for determining annotation content corresponding to the composition nodes in the main structure tree based on the text parsing result;
and the interface document generation module is used for generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree.
According to a third aspect of the present invention, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements an interface document generation method according to an embodiment of the present application.
According to a fourth aspect of the present invention, an electronic device is provided in an embodiment of the present application, and includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the interface document generation method according to the embodiment of the present application.
According to the technical scheme of the embodiment of the application, the target code text is analyzed, the target main class in the target code text is determined based on the text analysis result, and a main structure tree of the target main class is constructed; determining annotation contents corresponding to the composition nodes in the main structure tree based on the text analysis result; and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. According to the method and the device, the interface document of the target code text can be automatically generated under the condition that the target code text is not invaded, the generation efficiency of the interface document is improved, and the generation cost of the interface document is reduced. According to the method and the device, the interface document of the target code text is generated based on the annotation content in the text analysis result, and the accuracy and readability of the interface document are guaranteed.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present application, nor do they limit the scope of the present application. Other features of the present application will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow diagram of a method for interface document generation provided in accordance with an embodiment;
FIG. 2 is a flowchart of an interface document generation method provided according to a second embodiment;
FIG. 3 is a flowchart of an interface document generation method provided according to the third embodiment;
FIG. 4 is a schematic structural diagram of an interface document generating apparatus according to a fourth embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," "target," and "candidate" and the like in the description and claims of this application and the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example one
FIG. 1 is a flowchart of an interface document generation method according to an embodiment, which is applicable to a case where an interface document is generated for a code text in a process of product development using Java language. The method may be performed by an interface document generation apparatus, which may be implemented in hardware and/or software, and may be integrated in an electronic device running the system.
As shown in fig. 1, the method includes:
s110, determining a target code text according to the interface document generation request, and analyzing the target code text to obtain a text analysis result.
Wherein the interface document generation request is used for requesting the target code text to generate the interface document. Optionally, the interface document generation request includes a text acquisition path of the target code text. And determining a target code file according to the interface document generation request, and acquiring a target code text based on a text acquisition path in the interface document generation request. The target code text needs to generate a code text of the interface document, and optionally, the target code text is a code text written by using a Java language, and the target code text belongs to a Java class text.
And optionally, analyzing the target code text based on the text arrangement sequence of the target code text to obtain a text analysis result. The target code text is analyzed, the target code text is not invaded, and the target code text is not changed.
And S120, determining a target main class in the target code text based on the text analysis result, and constructing a main structure tree of the target main class.
The Java language is an object-oriented programming language, the basic building blocks of which are classes, including fields and methods, each program must contain a main () method, and the class containing the main () method becomes the main class. The main class is an execution entry of the Java program, and there may be a plurality of classes in one Java program, but only one class is the main class.
The object code text is analyzed, and the classes, attributes and methods in the object code text can be exposed.
And determining a target main class in the target code text based on the text parsing result. The target main class refers to a main class in the target code text. That is, the object code text includes a class of main () methods.
Wherein the main structure tree of the target main class is used for determining the hierarchy among the elements included in the target main class. Determining elements such as methods and fields in the target main class based on the text analysis result, constructing a main structure tree of the target main class according to the elements in the target main class, optionally, taking the elements in the target main class as constituent nodes in the main structure tree, determining the levels of the constituent nodes in the main structure tree according to the level relation among the constituent nodes.
S130, determining annotation contents corresponding to the composition nodes in the main structure tree based on the text analysis result.
The text analysis result comprises all contents in the target code text, and the text analysis result comprises annotation contents corresponding to the composition nodes. It can be known that the annotation content is just the explanation and description of the code, and the annotation content can reduce the difficulty of understanding the code.
The annotation content corresponding to the composition node is used for explaining the corresponding composition node. That is, the annotation content is used to interpret elements such as methods or fields in the target major class, and the annotation content includes an element usage description. Based on the annotation content corresponding to the composition node, the interface usage description involved in the target main class can be determined.
Optionally, in the case of determining a constituent node in the main structure tree, based on a text parsing result, annotation content corresponding to the constituent node in the main structure tree is determined.
S140, generating an interface document of the target code text according to the annotation content corresponding to the nodes in the main structure tree.
The interface document is used for constraining the collaborative development of the front end and the back end, the interface document comprises an interface definition specification, and developers at the front end and the back end need to abide by together. The annotation content is the data basis on which the interface document is generated.
And generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. Specifically, the node hierarchy where the nodes are formed in the main structure tree determines the interface call relationship of the interface involved in the target main class. And determining the interface use description of the interface involved in the target main class based on the annotation content corresponding to the composition node.
And generating an interface document of the target code text according to the interface calling relation and the interface use description.
According to the technical scheme of the embodiment of the application, the target code text is analyzed, the target main class in the target code text is determined based on the text analysis result, and a main structure tree of the target main class is constructed; determining annotation content corresponding to the composition nodes in the main structure tree based on the text analysis result; and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. According to the method and the device, the interface document of the target code text can be automatically generated without additionally adding codes on the interface providing services to the outside under the condition of not invading the target code text, so that the generation efficiency of the interface document is improved, and the generation cost of the interface document is reduced. According to the method and the device, the interface document of the target code text is generated based on the annotation content in the text analysis result, the interface calling method and the interface applicable service can be known clearly, and the accuracy and the readability of the interface document are guaranteed.
In an optional embodiment, determining the target major class in the target code text based on the text parsing result includes: and matching the class regular expression with the text analysis result, and determining a target main class in the target code text according to the matching result.
The class regular expression is used for positioning a target main class in the target code text in the text analysis result. The quasi-regular expression is constructed in advance according to the code writing specification, and the quasi-regular expression is not limited in the method and is constructed according to the actual situation. And matching the similar regular expression with the text analysis result to obtain a matching result. Optionally, the matching result includes matching success and matching failure. If the matching is successful, the target main class is successfully positioned in the text analysis result, and the class name of the target main class is determined. And if the matching result is matching failure, indicating that the target main class is not positioned in the text analysis result. Optionally, a feedback message indicating that the main positioning fails is generated for the interface document generation request.
According to the technical scheme, the target main class in the target code text is determined by matching the class regular expression with the text analysis result, a feasible main class determination scheme is provided, and data support is provided for generating the interface document.
In a specific embodiment, after determining, based on the text parsing result, annotation content corresponding to the composition node in the main structure tree, the method further includes: and associating the acquired annotation content with the corresponding component node in the main structure tree, and updating the processing label of the component node to be processed.
And the composition nodes in the main structure tree have corresponding processing labels. It may be determined whether the component node has performed an annotation content retrieval operation based on the processing tag of the component node. Optionally, the processed tag is initialized as unprocessed. After associating the annotation content to the corresponding component node, the processing tag of the component node is updated to processed.
According to the technical scheme, the processing labels are set for the composition nodes in the main structure tree, and after the annotation content is associated with the corresponding composition nodes in the main structure tree, the processing labels of the composition nodes are updated to be processed. Whether the annotation content acquisition operation is executed on the component nodes can be quickly determined based on the processing tag, the situation that the annotation content is omitted due to the fact that the number of the component nodes is too large is avoided, and the generation efficiency of the interface document and the accuracy of the interface document are improved.
Example two
FIG. 2 is a flowchart of an interface document generation method provided according to the second embodiment. The present embodiment performs further optimization based on the above embodiments, and specifically, refines the operation "construct the main structure tree of the target main class".
As shown in fig. 2, the method includes:
s210, determining a target code text according to the interface document generation request, and analyzing the target code text to obtain a text analysis result.
S220, determining a target main class in the target code text based on the text analysis result, instantiating the target main class based on a Java reflection principle, and determining target elements included in the target main class according to the instantiation result of the target main class.
Wherein, the target element belongs to the target main class, and the target element can be a method or a field. The Java reflection principle is a mechanism for dynamically acquiring information and dynamically calling object methods. The Java reflection principle means that all fields and methods of any class can be known in the program running state; and any method thereof can be called for any object.
And determining a target main class in the target code text based on the text analysis result, and optionally determining the class name of the target main class. And instantiating the target main class based on the Java reflection principle to obtain an instantiation result. All fields and methods in the target main class are included in the instantiation result, and the fields and methods belonging to the target main class are determined as target elements included in the target main class.
And S230, constructing a main structure tree of the target main class based on the element type of the target element.
The element type determines the level at which the target element is located in the main structure tree. That is, the shape of the main structure tree is determined by the element type of the target element.
S240, determining annotation content corresponding to the composition nodes in the main structure tree based on the text analysis result.
And S250, generating an interface document of the target code text according to the annotation content corresponding to the nodes in the main structure tree.
According to the technical scheme, the Java reflection principle is used for generating the interface document, the target main class is instantiated based on the Java reflection principle, the target elements included in the target main class are determined according to the instantiation result of the target main class, the main structure tree of the target main class is constructed based on the element types of the target elements, and technical support is provided for automatically generating the interface document under the condition that the target code text is not invaded.
In an optional embodiment, the building a main structure tree of the target main class based on the element type of the target element includes: taking the target element as a composition node of the main structure tree; determining a level of a constituent node corresponding to the target element in the main structure tree based on the element type of the target element; and constructing a main structure tree of the target main class based on the node hierarchy corresponding to the target element.
The target element belongs to a target main class, and optionally, the target element comprises a method, a field and a parameter. According to the element type of the target elements, the hierarchical relationship between the target elements can be determined. And taking the target elements as the constituent nodes of the main structure tree, and determining the level of the constituent nodes corresponding to the target elements in the main structure tree according to the level relation among the target elements. And under the condition that the composition nodes and the levels of the composition nodes in the main structure tree are determined, constructing the main structure tree of the target main class.
Optionally, the element type is a target element of the method, and the target element is used as a first-level node in the main structure tree; taking the target element with the element type as a parameter as a secondary node in the class structure tree; and taking the element type as a target element of the field as a three-level node in the class structure tree. Wherein the parameters comprise an input parameter and an output parameter. Both the input parameter and the output parameter can be used as three-level nodes. Doing so may generate an interface document that includes the in-participation and the out-participation.
According to the technical scheme, the target elements in the target main class are used as the constituent nodes of the main structure tree, the hierarchy of the constituent nodes in the main structure tree is determined based on the element types of the target elements, a feasible main structure tree construction scheme is provided, and data support is provided for generating the interface document.
In an optional embodiment, the method further comprises: determining whether the element type of a leaf node in the main structure tree belongs to a basic type; if the element type of the leaf node does not belong to the basic type, determining a secondary element included by the leaf node; taking secondary elements of which the element types belong to basic types as composition nodes, and constructing a sub-structure tree for the leaf nodes; and determining annotation content corresponding to the composition nodes in the sub-structure tree based on the text analysis result.
Wherein, the leaf node refers to a component node with the middle of 0 in the main structure tree. The leaf nodes are constituent nodes at the last level in the main structure tree. The leaf nodes correspond to target elements in the target major class. It is determined whether the element type of the leaf node belongs to the base type. Wherein the base type is a string, a number, or a boolean. If the element type of the leaf node belongs to the basic type, the leaf node does not comprise the secondary node any more, and the main structure tree is constructed. If the element type of the leaf node does not belong to the basic type, the main structure tree is not constructed, secondary elements included by the leaf node are determined, whether the element type of the secondary elements belongs to the basic type or not is determined, if the secondary elements do not belong to the basic type, the current secondary elements are determined to be transition nodes, the secondary elements included by the transition nodes are determined, and if the element type of the secondary elements does not belong to the basic type, the transition nodes are updated by the secondary nodes. And repeating the above process until the secondary node of the transition node belongs to the basic type, taking the secondary element of which the element type belongs to the basic type as a composition node, and constructing the sub-structure tree for the leaf node. The sub-structure tree belongs to a leaf node. There is only one node level in the sub-structure tree, and the element types of the nodes in the sub-structure tree are basic types. The sub-structure tree takes leaf nodes in the main structure tree as root nodes. And determining annotation content corresponding to the composition nodes in the sub-structure tree based on the text analysis result. Optionally, the obtained annotation content is associated with a corresponding component node in the sub-structure tree, and the processing tag of the component node is updated to be processed. Optionally, the obtaining manner of the annotation content corresponding to the composition node in the sub-structure tree is consistent with the obtaining manner of the annotation content corresponding to the composition node in the main structure tree. For details, reference will be made to the following examples.
According to the technical scheme, whether the element types of the leaf nodes in the main structure tree belong to basic types is determined; if the element type of the leaf node does not belong to the basic type, determining secondary elements included by the leaf node; taking secondary elements of which the element types belong to the basic types as composition nodes, and constructing a sub-structure tree for leaf nodes; based on the text analysis result, the annotation content corresponding to the composition node in the sub-structure tree is determined, the integrity of the main structure tree is ensured, and the accuracy of the interface document is further ensured.
EXAMPLE III
FIG. 3 is a flowchart of an interface document generation method provided according to the third embodiment. The present embodiment is further optimized on the basis of the foregoing embodiment, and specifically, an operation "determining annotation content corresponding to a component node in the main structure tree based on the text parsing result" is refined.
As shown in fig. 3, the method includes:
s310, determining a target code text according to the interface document generation request, and analyzing the target code text to obtain a text analysis result.
S320, determining a target main class in the target code text based on the text analysis result, and constructing a main structure tree of the target main class.
Optionally, when the construction of the main structure tree is completed, a corresponding relationship between a node hierarchy of the constituent nodes in the main structure tree and the element types is constructed.
S330, determining a target node from the main structure tree according to the processing labels of the nodes formed in the main structure tree.
According to the processing labels of the composition nodes in the main structure tree, which composition nodes in the main structure tree have not executed the annotation obtaining operation can be determined. Optionally, the treatment tag includes treated and untreated. And selecting the component nodes with the processing labels as unprocessed as target nodes. Optionally, if the number of the unprocessed component nodes in the processing tag is greater than 2, the target node is determined according to the node hierarchy of the component nodes, and it is ensured that all the component nodes in the main structure tree execute the annotation obtaining operation.
S340, generating an element regular expression of the target node according to the node level and the node identification of the target node.
And the node hierarchy of the target node is determined according to the element type of the target element corresponding to the target node. The element type is used to determine an element regular expression. The element regular expression is used for positioning a target element in the target code text in the text analysis result. The element types affect the expression forms of the element regular expressions, the element types are different, and the expression forms of the corresponding element regular expressions are different.
The element regular expression is constructed in advance according to the code writing specification, and is not limited herein, and is constructed according to the actual situation. And elements of the same type, wherein the expression forms of the corresponding element regular expressions are the same.
And the node identification of the target node is used for distinguishing different target nodes, the node identification of the target node is used for generating an element regular expression, and the element regular expression belonging to the target node is generated.
And S350, matching the element regular expression with the text analysis result, and extracting annotation content corresponding to the target node from the text analysis result according to the matching result.
And matching the element regular expression with a text analysis result, wherein optionally, the matching result comprises matching success and matching failure. If the matching is successful, the target element is successfully positioned in the text analysis result, and the element name of the target element is determined. And if the matching result is matching failure, indicating that the target element is not positioned in the text analysis result. Specifically, the element name of the target element is located in the text parsing result based on the element regular expression.
And S360, generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree.
It is to be understood that the annotation content is generally recorded at a determined position in the text parsing result, and the position of the annotation content in the text parsing result can be determined as the position information of the annotation content according to the position of the element name of the target element in the text parsing result. And acquiring the annotation content corresponding to the composition node according to the position information of the annotation content, and generating an interface document of the target code text.
According to the technical scheme, the target node is determined from the main structure tree according to the processing labels of the nodes formed in the main structure tree; generating an element regular expression of the target node according to the node level and the node identification of the target node; matching the element regular expression with the text analysis result, and extracting annotation content corresponding to the target node from the text analysis result according to the matching result; and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. According to the method and the device, the element regular expression is used for generating the interface document, and technical support is provided for automatically generating the interface document under the condition that the target code text is not invaded.
Example four
Fig. 4 is a schematic structural diagram of an interface document generating apparatus according to a fourth embodiment of the present application, which is applicable to a case where an interface document is generated for a code text in a process of developing a product using Java language. The device can be realized by software and/or hardware, and can be integrated in electronic equipment such as an intelligent terminal.
As shown in fig. 4, the apparatus may include: a code text parsing module 410, a main structure tree construction module 420, an annotation content determination module 430, and an interface document generation module 440.
The code text analysis module 410 is configured to determine a target code text according to the interface document generation request, and analyze the target code text to obtain a text analysis result;
a main structure tree construction module 420, configured to determine a target main class in the target code text based on the text parsing result, and construct a main structure tree of the target main class;
an annotation content determining module 430, configured to determine annotation content corresponding to a component node in the main structure tree based on the text parsing result;
and an interface document generating module 440, configured to generate an interface document of the target code text according to the annotation content corresponding to the composition node in the main structure tree.
According to the technical scheme of the embodiment of the application, the target code text is analyzed, the target main class in the target code text is determined based on the text analysis result, and a main structure tree of the target main class is constructed; determining annotation contents corresponding to the composition nodes in the main structure tree based on the text analysis result; and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree. According to the method and the device, the interface document of the target code text can be automatically generated under the condition that the target code text is not invaded, the generation efficiency of the interface document is improved, and the generation cost of the interface document is reduced. According to the method and the device, the interface document of the target code text is generated based on the annotation content in the text analysis result, and the accuracy and readability of the interface document are guaranteed.
Optionally, the main structure tree constructing module 420 is specifically configured to match the class regular expression with the text parsing result, and determine a target main class in the target code text according to a matching result.
Optionally, the main structure tree building module 420 includes: the target element determination sub-module is used for instantiating the target main class based on a Java reflection principle and determining target elements included in the target main class according to an instantiation result of the target main class; and the main structure tree construction submodule is used for constructing the main structure tree of the target main class based on the element type of the target element.
Optionally, the main structure tree constructing sub-module includes: a composition node determining unit, configured to use the target element as a composition node of the main structure tree; a node hierarchy determining unit, configured to determine, based on an element type of the target element, a hierarchy in the main structure tree in which a constituent node corresponding to the target element is located; and the main structure tree construction unit is used for constructing the main structure tree of the target main class based on the node hierarchy corresponding to the target element.
Optionally, the annotation content determining module 430 includes: the target node determining submodule is used for determining a target node from the main structure tree according to the processing labels of the nodes formed in the main structure tree; the expression generation submodule is used for generating an element regular expression of the target node according to the node level and the node identification of the target node; and the annotation content extraction submodule is used for matching the element regular expression with the text analysis result and extracting annotation content corresponding to the target node from the text analysis result according to the matching result.
Optionally, the device is further configured to, after determining annotation content corresponding to a component node in the main structure tree based on the text parsing result, associate the obtained annotation content with the corresponding component node in the main structure tree, and update a processing tag of the component node to be processed.
Optionally, the apparatus further comprises: the element type judging module is used for determining whether the element type of the leaf node in the main structure tree belongs to a basic type; a secondary element determining module, configured to determine a secondary element included in the leaf node if the element type of the leaf node does not belong to a basic type; the sub-structure tree building module is used for building a sub-structure tree for the leaf nodes by taking secondary elements of which the element types belong to the basic types as composition nodes; and the annotation content determining module is used for determining annotation content corresponding to the composition nodes in the sub-structure tree based on the text analysis result.
The interface document generation device provided by the embodiment of the invention can execute the interface document generation method provided by any embodiment of the application, and has the corresponding performance module and the beneficial effect of executing the interface document generation method.
In the technical scheme of the disclosure, the collection, storage, use, processing, transmission, provision, disclosure and the like of the related user information all accord with the regulations of related laws and regulations, and do not violate common orderliness.
EXAMPLE five
FIG. 5 illustrates a schematic diagram of an electronic device 510, which can be used to implement an embodiment. The electronic device 510 includes at least one processor 511, and a memory communicatively connected to the at least one processor 511, such as a Read Only Memory (ROM) 512, a Random Access Memory (RAM) 513, and so on, wherein the memory stores computer programs executable by the at least one processor, and the processor 511 may perform various suitable actions and processes according to the computer programs stored in the Read Only Memory (ROM) 512 or the computer programs loaded from the storage unit 518 into the Random Access Memory (RAM) 513. In the RAM 513, various programs and data necessary for the operation of the electronic device 510 can also be stored. The processor 511, the ROM 512, and the RAM 513 are connected to each other by a bus 514. An input/output (I/O) interface 515 is also connected to bus 514.
Various components in the electronic device 510 are connected to the I/O interface 515, including: an input unit 516 such as a keyboard, a mouse, or the like; an output unit 517 such as various types of displays, speakers, and the like; a storage unit 518, such as a magnetic disk, optical disk, or the like; and a communication unit 519 such as a network card, modem, wireless communication transceiver, or the like. A communication unit 519 allows the electronic device 510 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks.
Processor 511 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of processor 511 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 511 performs the various methods and processes described above, such as the interface document generation method.
In some embodiments, the interface document generation method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 518. In some embodiments, some or all of the computer program may be loaded onto and/or installed onto the electronic device 510 via the ROM 512 and/or the communication unit 519. When the computer program is loaded into RAM 513 and executed by processor 511, one or more steps of the interface document generation method described above may be performed. Alternatively, in other embodiments, the processor 511 may be configured by any other suitable means (e.g., by means of firmware) to perform the interface document generation method.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of this application, a computer readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data processing server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above, reordering, adding or deleting steps, may be used. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired results of the technical solutions of the present application can be achieved.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. An interface document generation method, characterized in that the method comprises:
determining a target code text according to an interface document generation request, and analyzing the target code text to obtain a text analysis result;
determining a target main class in the target code text based on the text analysis result, and constructing a main structure tree of the target main class;
determining annotation content corresponding to the composition nodes in the main structure tree based on the text analysis result;
and generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree.
2. The method of claim 1, wherein determining a target major class in the target code text based on the text parsing result comprises:
and matching the class regular expression with the text analysis result, and determining a target main class in the target code text according to the matching result.
3. The method of claim 1, wherein constructing the main structure tree of the target main class comprises:
instantiating the target main class based on a Java reflection principle, and determining target elements included in the target main class according to an instantiation result of the target main class;
and constructing a main structure tree of the target main class based on the element type of the target element.
4. The method according to claim 3, wherein the building the main structure tree of the target main class based on the element type of the target element comprises:
taking the target element as a composition node of the main structure tree;
determining the level of a composition node corresponding to the target element in the main structure tree based on the element type of the target element;
and constructing a main structure tree of the target main class based on the node hierarchy corresponding to the target element.
5. The method according to claim 1, wherein determining annotation contents corresponding to the composition nodes in the main structure tree based on the text parsing result comprises:
determining a target node from the main structure tree according to the processing labels of the nodes in the main structure tree;
generating an element regular expression of the target node according to the node level and the node identification of the target node;
and matching the element regular expression with the text analysis result, and extracting annotation content corresponding to the target node from the text analysis result according to the matching result.
6. The method of claim 1, wherein after determining annotation content corresponding to a component node in the main structure tree based on the text parsing result, the method further comprises:
and associating the acquired annotation content with the corresponding component node in the main structure tree, and updating the processing label of the component node to be processed.
7. The method of claim 1, further comprising:
determining whether the element type of a leaf node in the main structure tree belongs to a basic type;
if the element type of the leaf node does not belong to the basic type, determining a secondary element included by the leaf node;
taking secondary elements of which the element types belong to basic types as composition nodes, and constructing a sub-structure tree for the leaf nodes;
and determining annotation content corresponding to the composition nodes in the sub-structure tree based on the text analysis result.
8. An interface document generation apparatus, characterized in that the apparatus comprises:
the code text analysis module is used for determining a target code text according to the interface document generation request and analyzing the target code text to obtain a text analysis result;
the main structure tree construction module is used for determining a target main class in the target code text based on the text analysis result and constructing a main structure tree of the target main class;
the annotation content determining module is used for determining annotation content corresponding to the composition nodes in the main structure tree based on the text parsing result;
and the interface document generation module is used for generating an interface document of the target code text according to the annotation content corresponding to the composition nodes in the main structure tree.
9. A computer-readable storage medium on which a computer program is stored, which program, when being executed by a processor, is characterized by carrying out the interface document generation method according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the interface document generation method according to any one of claims 1 to 7 when executing the computer program.
CN202211686476.6A 2022-12-26 2022-12-26 Interface document generation method, device, medium and electronic equipment Pending CN115934101A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211686476.6A CN115934101A (en) 2022-12-26 2022-12-26 Interface document generation method, device, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211686476.6A CN115934101A (en) 2022-12-26 2022-12-26 Interface document generation method, device, medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115934101A true CN115934101A (en) 2023-04-07

Family

ID=86552178

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211686476.6A Pending CN115934101A (en) 2022-12-26 2022-12-26 Interface document generation method, device, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115934101A (en)

Similar Documents

Publication Publication Date Title
CN114579104A (en) Data analysis scene generation method, device, equipment and storage medium
CN117610555A (en) Character string expression processing method, device, equipment and storage medium
CN117055851A (en) Software architecture recovery method and device, electronic equipment and storage medium
CN115186738B (en) Model training method, device and storage medium
CN115757304A (en) Log storage method, device and system, electronic equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN116303013A (en) Source code analysis method, device, electronic equipment and storage medium
CN115146070A (en) Key value generation method, knowledge graph generation method, device, equipment and medium
CN115934101A (en) Interface document generation method, device, medium and electronic equipment
CN114969444A (en) Data processing method and device, electronic equipment and storage medium
CN114443802A (en) Interface document processing method and device, electronic equipment and storage medium
CN114647727A (en) Model training method, device and equipment applied to entity information recognition
CN112989066A (en) Data processing method and device, electronic equipment and computer readable medium
CN113360672A (en) Methods, apparatus, devices, media and products for generating a knowledge graph
CN117093638B (en) Micro-service data initialization method, system, electronic equipment and storage medium
CN116431698B (en) Data extraction method, device, equipment and storage medium
CN117992598B (en) Demand response method, device, medium and equipment based on large model
CN116383454B (en) Data query method of graph database, electronic equipment and storage medium
CN116662563A (en) Skill culture knowledge graph generation method, device, equipment and medium
CN117667976A (en) Data processing method, device, equipment and storage medium
CN118170430A (en) Method, device, equipment and storage medium for processing call link
CN117931506A (en) Document verification method, device, equipment and storage medium
CN118133794A (en) Table configuration method, apparatus, device and storage medium
CN117764560A (en) Vehicle maintenance suggestion acquisition method and vehicle maintenance suggestion generation method
CN114861676A (en) Paragraph extraction method and device and electronic equipment

Legal Events

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