CN110262783B - Interface generation method and device and terminal equipment - Google Patents

Interface generation method and device and terminal equipment Download PDF

Info

Publication number
CN110262783B
CN110262783B CN201910431868.XA CN201910431868A CN110262783B CN 110262783 B CN110262783 B CN 110262783B CN 201910431868 A CN201910431868 A CN 201910431868A CN 110262783 B CN110262783 B CN 110262783B
Authority
CN
China
Prior art keywords
syntax tree
abstract syntax
interface
character string
file
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.)
Active
Application number
CN201910431868.XA
Other languages
Chinese (zh)
Other versions
CN110262783A (en
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.)
Shenzhen Huake Yun Power Technology Co ltd
Original Assignee
Shenzhen Huake Yun Power 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 Shenzhen Huake Yun Power Technology Co ltd filed Critical Shenzhen Huake Yun Power Technology Co ltd
Priority to CN201910431868.XA priority Critical patent/CN110262783B/en
Publication of CN110262783A publication Critical patent/CN110262783A/en
Application granted granted Critical
Publication of CN110262783B publication Critical patent/CN110262783B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • 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

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of data processing, and provides an interface generation method, an interface generation device and terminal equipment, wherein the method comprises the following steps: acquiring an API document, and extracting interface attribute elements in the API document; filling the interface attribute elements into an abstract syntax tree template to obtain a complete abstract syntax tree; and inputting character string literal values of the complete abstract syntax tree into a nim file to generate an interface source code file. The method and the device can solve the problem that the existing API is realized by writing codes by developers and needs to consume a great deal of time and energy of the developers.

Description

Interface generation method and device and terminal equipment
Technical Field
The application belongs to the technical field of data processing, and particularly relates to an interface generation method, an interface generation device and terminal equipment.
Background
The API (Application Programming Interface ) is a number of predefined functions that are intended to provide the application and developer the ability to access a set of routines based on certain software or hardware without having to access source code or understand the details of the internal operating mechanisms.
The current development and update maintenance mode of the API is that a developer writes code according to an API document, and when more APIs need to be developed or updated, the developer consumes a great deal of time and effort.
To sum up, the existing APIs are implemented by writing code by a developer, which requires much time and effort by the developer.
Disclosure of Invention
In view of this, the embodiments of the present application provide an interface generating method, apparatus, and terminal device, so as to solve the problem that the existing API is implemented by writing codes by a developer, and needs to consume a great deal of time and effort of the developer.
A first aspect of an embodiment of the present application provides an interface generating method, including:
acquiring an API document, and extracting interface attribute elements in the API document;
filling the interface attribute elements into an abstract syntax tree template to obtain a complete abstract syntax tree;
and inputting character string literal values of the complete abstract syntax tree into a nim file to generate an interface source code file.
A second aspect of an embodiment of the present application provides an interface generating device, including:
the element extraction module is used for acquiring an API document and extracting interface attribute elements in the API document;
the grammar tree module is used for filling the interface attribute elements into an abstract grammar tree template to obtain a complete abstract grammar tree;
and the source code module is used for inputting character string literal values of the complete abstract syntax tree into the nim file to generate an interface source code file.
A third aspect of the embodiments of the present application provides a terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method as described above when executing the computer program.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the method as described above.
Compared with the prior art, the embodiment of the application has the beneficial effects that:
in the interface generating method, interface attribute elements in an API document are extracted, the interface attribute elements are filled into an abstract syntax tree template to obtain a complete abstract syntax tree, and character string literal values of the complete abstract syntax tree are input into a nim file to generate an interface source code file.
Because the content contained in each API document and the interface source code written by the developer have a certain format rule, the interface attribute elements required in the API document can be extracted according to the format rule of the API document, the abstract syntax tree template is written according to the format rule of the interface source code, the process of manually writing the code by the developer is converted into the process of automatically filling the interface attribute elements into the abstract syntax tree template, then the character string literal values of the complete abstract syntax tree are input into the nim file to generate the interface source code file, the automatic generation of the interface is realized, and the problem that the existing API is realized by writing the code by the developer and a great amount of time and effort of the developer are required is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic implementation flow chart of an interface generating method according to an embodiment of the present application;
fig. 2 is a schematic diagram of an interface generating device according to an embodiment of the present application;
fig. 3 is a schematic diagram of a terminal device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to illustrate the technical solutions described in the present application, the following description is made by specific examples.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Embodiment one:
referring to fig. 1, the method for generating an interface in the first embodiment of the present application includes:
step S101, acquiring an API document, and extracting interface attribute elements in the API document;
when an interface needs to be generated, an API document can be acquired first, interface attribute elements can be extracted from the API document, and the interface attribute elements can comprise interface attribute elements such as interface names, parameter types, return values and the like.
The API document is a Web page in an HTML form, the page content of the API document can be obtained through a Nim Http request, written into an HTML file, and then the interface attribute element extraction operation is carried out.
Step S102, filling the interface attribute elements into an abstract syntax tree template to obtain a complete abstract syntax tree;
after the interface attribute elements are extracted, the interface attribute elements can be filled into an abstract syntax tree template, wherein the abstract syntax tree template is a universal template preset by a developer, the abstract syntax tree template is provided with blank nodes corresponding to the interface attribute elements, and the interface attribute elements are filled into the corresponding blank nodes to obtain a complete abstract syntax tree.
And step S103, inputting character string literal values of the complete abstract syntax tree into a nim file to generate an interface source code file.
After the complete abstract syntax tree is obtained, character string literal values of the complete abstract syntax tree can be input into the nim file to generate an interface source code file.
The Nim language is a static-type, imperative programming language that supports procedural, functional, object-oriented, and functional programming styles while remaining simple and efficient.
The Nim file is a code file corresponding to Nim language, and when the Nim file is used as an interface source code file, an abstract syntax tree template can be written by using the grammar of Nim language, so that the development difficulty of the abstract syntax tree template is reduced.
Further, the filling the interface attribute element into the abstract syntax tree template to obtain a complete abstract syntax tree concrete includes:
a1, filling the interface attribute elements into an abstract syntax tree template in a macro, and judging whether unfilled necessary nodes exist in the abstract syntax tree template;
when the interface attribute elements are filled, instructions can be written in macros, the interface attribute elements are filled in the abstract syntax tree template, then whether all necessary nodes in the abstract syntax tree template are filled with the corresponding interface attribute elements is judged, and if the necessary nodes are not filled with the corresponding interface attribute elements, the generated interface source code files cannot be compiled normally easily.
A2, when unfilled necessary nodes exist in the abstract syntax tree template, filling corresponding typical values in the unfilled necessary nodes to obtain a complete abstract syntax tree;
when the unfilled necessary nodes exist in the abstract syntax tree template, in order to ensure that the generated interface source code file can be compiled normally, corresponding typical values can be filled in the unfilled necessary nodes, and the abstract syntax tree template is completed, so that a complete abstract syntax tree is obtained.
A3, when the unfilled necessary nodes do not exist in the abstract syntax tree template, a complete abstract syntax tree is obtained.
When the necessary nodes in the abstract syntax tree have all been filled with the corresponding interface attribute elements, a complete abstract syntax tree may be obtained.
Further, the inputting the character string literal value of the complete abstract syntax tree into the nim file, and generating the interface source code file specifically includes:
b1, assigning character string literal values of the complete abstract syntax tree to preset character string variables in the macro;
after the complete abstract syntax tree is obtained through the macro, in order to export the complete abstract syntax tree generated in the macro, a character string variable can be predefined in the macro, and the character string literal value of the complete abstract syntax tree is given to a preset character string variable.
And B2, expanding the macro through a compiler to obtain the assignment of the character string variable, and inputting the assignment of the character string variable into a nim file to generate an interface source code file.
And then expanding the macro through a compiler to obtain assignment of the character string variable defined in the macro, namely, character string literal values of the complete abstract syntax tree, and then inputting the assignment of the character string variable into the nim file to generate the interface source code file.
Further, before the filling the interface attribute element into the abstract syntax tree template in the macro, determining whether there is an unfilled necessary node in the abstract syntax tree template further includes:
and C1, carrying out grammar conversion on the interface attribute elements according to the grammar format requirement of the Nim node.
When the interface attribute elements are extracted, the interface attribute elements are stored in the form of nodes, and in order to enable the interface attribute elements to meet the requirements of Nim language, the interface attribute elements can be subjected to grammar conversion according to the grammar format requirements of Nim nodes, and the interface attribute elements are organized into Nim nodes with correct grammar.
Further, the obtaining the API document, and extracting the interface attribute element in the API document specifically includes:
and D1, acquiring an API document, and extracting interface attribute elements in the API document in an XMLNODE object mode.
When the interface attribute elements in the API document are extracted, a filter can be built in an XMLnod object mode, and the content in the API document is filtered to extract the interface attribute elements.
In the actual testing process, the testing has been performed in the Tencent cloud API document, the Arian cloud API document, the AWS API document, the Vulkan document and the VMware python SDK, the corresponding interface source code files can be automatically generated, VMware python SDK is taken as an example, 3931 API documents are sorted from VMware python SDK, the documents are presented in a obvious format rule and can be analyzed by Nim, after macro writing and debugging optimization, the interface generating method is applied to process the API documents, the interface source code files are generated for only 30 seconds, and for skilled developers, if handwriting codes are needed, the interface generating method of the embodiment can greatly reduce the time and effort consumed by the developers for developing interfaces.
In the interface generating method provided by the first embodiment, the interface attribute elements in the API document are extracted, the interface attribute elements are filled into the abstract syntax tree template to obtain a complete abstract syntax tree, and then the character string literal values of the complete abstract syntax tree are input into the nim file to generate the interface source code file.
Because the content contained in each API document and the interface source code written by the developer have a certain format rule, the interface attribute elements required in the API document can be extracted according to the format rule of the API document, the abstract syntax tree template is written according to the format rule of the interface source code, the process of manually writing the code by the developer is converted into the process of automatically filling the interface attribute elements into the abstract syntax tree template, then the character string literal values of the complete abstract syntax tree are input into the nim file to generate the interface source code file, the automatic generation of the interface is realized, and the problem that the existing API is realized by writing the code by the developer and a great amount of time and effort of the developer are required is solved.
After the interface attribute elements are filled into the abstract syntax tree template, whether unfilled necessary nodes exist in the abstract syntax tree template can be judged, if yes, corresponding typical values are filled in the filled necessary nodes, normal compiling of the generated source code file is ensured, and if all the necessary nodes are filled, a complete abstract syntax tree is obtained.
When a complete abstract syntax tree is obtained in a macro, in order to derive the complete abstract syntax tree, a character string variable can be predefined in the macro, character string literal values of the complete abstract syntax tree are given to preset character string variables, then the macro is unfolded through a compiler to obtain assignment of the character string variables, the character string literal values of the complete abstract syntax tree are derived to the outside of the macro, and then the assignment of the character string variables is input into a nim file to generate an interface source code file.
When the interface attribute element is extracted, in order to enable the interface attribute element to meet the requirements of Nim language, the interface attribute element can be subjected to grammar conversion according to the grammar format requirements of Nim nodes, and the interface attribute element is organized into Nim nodes with correct grammar.
When extracting the interface attribute element, the interface attribute element in the API document can be extracted by the XMLNODE object mode.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Embodiment two:
a second embodiment of the present application provides an interface generating device, for convenience of description, only a portion related to the present application is shown, and as shown in fig. 2, the interface generating device includes,
an element extraction module 201, configured to obtain an API document, and extract an interface attribute element in the API document;
the syntax tree module 202 is configured to populate the interface attribute element into an abstract syntax tree template to obtain a complete abstract syntax tree;
and the source code module 203 is configured to input the character string literal value of the complete abstract syntax tree into a nim file, and generate an interface source code file.
Further, the syntax tree module 202 specifically includes:
the node judging sub-module is used for filling the interface attribute elements into an abstract syntax tree template in a macro and judging whether unfilled necessary nodes exist in the abstract syntax tree template or not;
a typical filling sub-module, configured to, when an unfilled necessary node exists in the abstract syntax tree template, fill a corresponding typical value in the unfilled necessary node, so as to obtain a complete abstract syntax tree;
and the satisfactory filling sub-module is used for obtaining a complete abstract syntax tree when unfilled necessary nodes do not exist in the abstract syntax tree template.
Further, the source code module 203 specifically includes:
a literal value sub-module, configured to assign a character string literal value of the complete abstract syntax tree to a preset character string variable in the macro;
and the file generation sub-module is used for expanding the macro through a compiler to obtain the assignment of the character string variable, inputting the assignment of the character string variable into the nim file and generating an interface source code file.
Further, the apparatus further comprises:
and the grammar conversion module is used for carrying out grammar conversion on the interface attribute elements according to the grammar format requirement of the Nim node.
Further, the element extraction module 201 is specifically configured to obtain an API document, and extract an interface attribute element in the API document by means of an XMLNode object.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein again.
Embodiment III:
fig. 3 is a schematic diagram of a terminal device according to a third embodiment of the present application. As shown in fig. 3, the terminal device 3 of this embodiment includes: a processor 30, a memory 31 and a computer program 32 stored in said memory 31 and executable on said processor 30. The processor 30, when executing the computer program 32, implements the steps in the above-described interface generation method embodiment, such as steps S101 to S103 shown in fig. 1. Alternatively, the processor 30 may perform the functions of the modules/units of the apparatus embodiments described above, such as the functions of the modules 201 to 203 shown in fig. 2, when executing the computer program 32.
By way of example, the computer program 32 may be partitioned into one or more modules/units that are stored in the memory 31 and executed by the processor 30 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions for describing the execution of the computer program 32 in the terminal device 3. For example, the computer program 32 may be partitioned into an element extraction module, a syntax tree module, and a source code module, each of which functions specifically as follows:
the element extraction module is used for acquiring an API document and extracting interface attribute elements in the API document;
the grammar tree module is used for filling the interface attribute elements into an abstract grammar tree template to obtain a complete abstract grammar tree;
and the source code module is used for inputting character string literal values of the complete abstract syntax tree into the nim file to generate an interface source code file.
The terminal device 3 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The terminal device may include, but is not limited to, a processor 30, a memory 31. It will be appreciated by those skilled in the art that fig. 3 is merely an example of the terminal device 3 and does not constitute a limitation of the terminal device 3, and may include more or less components than illustrated, or may combine certain components, or different components, e.g., the terminal device may further include an input-output device, a network access device, a bus, etc.
The processor 30 may be a central processing unit (Central Processing Unit, CPU), other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 31 may be an internal storage unit of the terminal device 3, such as a hard disk or a memory of the terminal device 3. The memory 31 may be an external storage device of the terminal device 3, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 3. Further, the memory 31 may also include both an internal storage unit and an external storage device of the terminal device 3. The memory 31 is used for storing the computer program as well as other programs and data required by the terminal device. The memory 31 may also be used for temporarily storing data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each method embodiment described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (6)

1. An interface generation method, comprising:
acquiring an API document, and extracting interface attribute elements in the API document;
filling the interface attribute elements into an abstract syntax tree template to obtain a complete abstract syntax tree, wherein the method comprises the following steps: filling the interface attribute elements into an abstract syntax tree template in a macro, and judging whether unfilled necessary nodes exist in the abstract syntax tree template; when unfilled necessary nodes exist in the abstract syntax tree template, filling corresponding typical values in the unfilled necessary nodes to obtain a complete abstract syntax tree; when the unfilled necessary nodes do not exist in the abstract syntax tree template, a complete abstract syntax tree is obtained;
inputting character string literal values of the complete abstract syntax tree into a nim file to generate an interface source code file, wherein the method comprises the following steps of: assigning a character string literal value of the complete abstract syntax tree to a preset character string variable in the macro; and expanding the macro through a compiler to obtain the assignment of the character string variable, and inputting the assignment of the character string variable into a nim file to generate an interface source code file.
2. The interface generation method of claim 1, wherein before the populating the interface attribute element in the abstract syntax tree template in the macro, determining whether there are unfilled necessary nodes in the abstract syntax tree template further comprises:
and carrying out grammar conversion on the interface attribute elements according to the grammar format requirement of the Nim node.
3. The interface generating method according to claim 1, wherein the obtaining an API document, extracting an interface attribute element in the API document specifically includes:
and acquiring an API document, and extracting interface attribute elements in the API document in the mode of an XMLnod object.
4. An interface generating apparatus, comprising:
the element extraction module is used for acquiring an API document and extracting interface attribute elements in the API document;
the grammar tree module is used for filling the interface attribute elements into an abstract grammar tree template to obtain a complete abstract grammar tree; the grammar tree module specifically comprises: the node judging sub-module is used for filling the interface attribute elements into an abstract syntax tree template in a macro and judging whether unfilled necessary nodes exist in the abstract syntax tree template or not; a typical filling sub-module, configured to, when an unfilled necessary node exists in the abstract syntax tree template, fill a corresponding typical value in the unfilled necessary node, so as to obtain a complete abstract syntax tree; a round filling sub-module, configured to obtain a complete abstract syntax tree when no unfilled necessary node exists in the abstract syntax tree template;
the source code module is used for inputting character string literal values of the complete abstract syntax tree into a nim file to generate an interface source code file; the source code module specifically includes: a literal value sub-module, configured to assign a character string literal value of the complete abstract syntax tree to a preset character string variable in the macro; and the file generation sub-module is used for expanding the macro through a compiler to obtain the assignment of the character string variable, inputting the assignment of the character string variable into the nim file and generating an interface source code file.
5. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 3 when the computer program is executed.
6. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 3.
CN201910431868.XA 2019-05-22 2019-05-22 Interface generation method and device and terminal equipment Active CN110262783B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910431868.XA CN110262783B (en) 2019-05-22 2019-05-22 Interface generation method and device and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910431868.XA CN110262783B (en) 2019-05-22 2019-05-22 Interface generation method and device and terminal equipment

Publications (2)

Publication Number Publication Date
CN110262783A CN110262783A (en) 2019-09-20
CN110262783B true CN110262783B (en) 2023-08-08

Family

ID=67915217

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910431868.XA Active CN110262783B (en) 2019-05-22 2019-05-22 Interface generation method and device and terminal equipment

Country Status (1)

Country Link
CN (1) CN110262783B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111142871B (en) * 2019-12-24 2023-06-06 杭州安恒信息技术股份有限公司 Front-end page development system, method, equipment and medium
CN111158665B (en) * 2019-12-27 2023-07-18 网易(杭州)网络有限公司 Code generation method and device, electronic equipment and storage medium
CN111949253B (en) * 2020-08-07 2023-12-01 抖音视界有限公司 Method, apparatus, computer device and storage medium for combining IDL files
CN113238740B (en) * 2021-06-11 2023-10-27 腾讯科技(深圳)有限公司 Code generation method, code generation device, storage medium and electronic device
CN113778897B (en) * 2021-09-26 2024-03-29 网易有道信息技术(江苏)有限公司 Automatic test method, device and equipment for interface and storage medium
CN116501303B (en) * 2023-06-25 2023-11-14 北京长亭科技有限公司 Automatic API code generation method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140282373A1 (en) * 2013-03-15 2014-09-18 Trinity Millennium Group, Inc. Automated business rule harvesting with abstract syntax tree transformation
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN108108162A (en) * 2016-11-24 2018-06-01 腾讯科技(深圳)有限公司 Application programming interface generation method and device
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140282373A1 (en) * 2013-03-15 2014-09-18 Trinity Millennium Group, Inc. Automated business rule harvesting with abstract syntax tree transformation
CN108108162A (en) * 2016-11-24 2018-06-01 腾讯科技(深圳)有限公司 Application programming interface generation method and device
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110262783A (en) 2019-09-20

Similar Documents

Publication Publication Date Title
CN110262783B (en) Interface generation method and device and terminal equipment
CN111639287A (en) Page processing method and device, terminal equipment and readable storage medium
EP3679469A1 (en) Automating identification of test cases for library suggestion models
EP3679482A1 (en) Automating identification of code snippets for library suggestion models
WO2018226598A1 (en) Method and system for arbitrary-granularity execution clone detection
WO2019051388A1 (en) Automating generation of library suggestion engine models
CN111124479B (en) Method and system for analyzing configuration file and electronic equipment
CN111427583A (en) Component compiling method and device, electronic equipment and computer readable storage medium
CN104050085A (en) Forced code standard inspection method and system
CN110109671B (en) Webpack label size and style conversion method and device
CN111124382A (en) Attribute assignment method and device in Java and server
CN107766036B (en) Module construction method and device and terminal equipment
CN110096264A (en) A kind of code operation method and device
CN113805890A (en) Method, device, terminal, system and storage medium for migrating applets across applications
CN105068853A (en) Channel package output method and apparatus
CN111767217A (en) JS unit test case generation method and device
CN109828759B (en) Code compiling method, device, computer device and storage medium
CN108427580A (en) Configure detection method, storage medium and the smart machine repeated to name
CN111309332A (en) File content on-demand loading method and device, electronic equipment and storage medium
CN110058849A (en) Generation method, device, computer equipment and the storage medium of flow chart
CN111444456B (en) Style editing method and device and electronic equipment
CN110737431B (en) Software development method, development platform, terminal device and storage medium
CN113961238A (en) Object conversion method and device, electronic equipment and storage medium
CN109783134B (en) Front-end page configuration method and device and electronic equipment
CN109725932B (en) Method and device for generating description document of application component

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
GR01 Patent grant
GR01 Patent grant