CN109634579B - Code generation method, device, computer device and storage medium - Google Patents

Code generation method, device, computer device and storage medium Download PDF

Info

Publication number
CN109634579B
CN109634579B CN201811270329.4A CN201811270329A CN109634579B CN 109634579 B CN109634579 B CN 109634579B CN 201811270329 A CN201811270329 A CN 201811270329A CN 109634579 B CN109634579 B CN 109634579B
Authority
CN
China
Prior art keywords
page
document
layout
android
interaction
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
CN201811270329.4A
Other languages
Chinese (zh)
Other versions
CN109634579A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811270329.4A priority Critical patent/CN109634579B/en
Publication of CN109634579A publication Critical patent/CN109634579A/en
Application granted granted Critical
Publication of CN109634579B publication Critical patent/CN109634579B/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/44Encoding
    • G06F8/447Target code generation
    • 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)
  • Document Processing Apparatus (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention provides a code generation method, which comprises the following steps: acquiring a demand document of a target page, wherein the demand document comprises a layout demand document and an interaction demand document; acquiring page elements of the target page from the layout requirement document; converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document; acquiring interaction information of the target page from the interaction requirement document; and creating an interaction code of the target page in an active component associated with the android layout document according to the interaction information. The invention also discloses a code generating device, a computer device and a computer readable storage medium. The invention can shorten the code development time and improve the code development efficiency.

Description

Code generation method, device, computer device and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code generating method, a code generating device, a computer device, and a storage medium.
Background
Currently, when developing a mobile terminal application, code development is usually performed according to a design document. Specifically, the design document includes a visual document for developing a layout of a page, which may also be referred to as a layout document, and an interactive document through which a code for a page display can be written visually and an interactive process can be written.
The code development is carried out by the prior art, the time occupied by the code development in the project is generally longer, and if the application version iterates faster, the development cannot be completed in a short period when more contents need to be developed, so that the project is delayed.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a code generation method, apparatus, computer apparatus, and storage medium that can shorten the time for code development and improve the efficiency of code development.
The invention provides a code generation method, which comprises the following steps:
acquiring a demand document of a target page, wherein the demand document comprises a layout demand document and an interaction demand document;
acquiring page elements of the target page from the layout requirement document;
converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document;
acquiring interaction information of the target page from the interaction requirement document;
and creating an interaction code of the target page in an active component associated with the android layout document according to the interaction information.
In an optional implementation of the present invention, after the creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information, the method further includes:
Starting the movable component and receiving interactive operation of a preset operable object included in the movable component;
acquiring an interaction result of the interaction operation;
judging whether the interaction result is an expected interaction result or not;
and if the interaction result is not the expected interaction result, outputting a first operation error prompt.
In an optional embodiment of the invention, after creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information, the method further includes:
starting the movable component to display the target page;
acquiring a display picture from the target page and acquiring a page demand picture according to the layout demand document;
matching the display picture with the page demand picture;
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, outputting a second operation error prompt.
In an alternative implementation of the present invention, the android layout document and the active component associated with the android layout document are pre-created.
In an alternative implementation of the present invention, the method further includes:
and if the page element of the target page cannot be acquired from the layout requirement document, outputting an error reminding message.
In an alternative embodiment of the present invention, the method further comprises:
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, marking and displaying the display range of the display picture in the target page.
In an optional embodiment of the present invention, the obtaining the interaction information of the target page from the interaction requirement document includes:
and scanning the interaction requirement document, acquiring an operable object with the same identifier as the layout requirement document, and identifying the interaction operation of the operable object to obtain the interaction information of the target page.
The present invention provides a code generation apparatus, the apparatus comprising:
the system comprises a first acquisition module, a second acquisition module and a first processing module, wherein the first acquisition module is used for acquiring a demand document of a target page, and the demand document comprises a layout demand document and an interaction demand document;
the second acquisition module is used for acquiring page elements of the target page from the layout requirement document;
the first generation module is used for converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document;
the third acquisition module is used for acquiring the interaction information of the target page from the interaction requirement document;
And the second generation module is used for creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information.
In an alternative embodiment of the present invention, the apparatus further includes a first verification module, where the first verification module is configured to:
after the interactive code of the target page is created in the active component associated with the android layout document according to the interactive information, starting the active component, and receiving interactive operation of a preset operable object included in the active component;
acquiring an interaction result of the interaction operation;
judging whether the interaction result is an expected interaction result or not;
and if the interaction result is not the expected interaction result, outputting a first operation error prompt.
In an alternative embodiment of the invention, the apparatus further comprises a second checking module for:
after the interactive codes of the target pages are created in the active components associated with the android layout document according to the interactive information, starting the active components to display the target pages;
acquiring a display picture from the target page and acquiring a page demand picture according to the layout demand document;
Matching the display picture with the page demand picture;
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, outputting a second operation error prompt.
In an alternative embodiment of the present invention, the android layout document and the active component associated with the android layout document are pre-created.
In an alternative embodiment of the present invention, the apparatus further comprises:
and the reminding module is used for outputting an error reminding message if the page element of the target page cannot be acquired from the layout requirement document.
In an alternative embodiment of the present invention, the apparatus further comprises:
and the marking display module is used for marking and displaying the display range of the display picture in the target page if the similarity between the display picture and the page demand picture is lower than the preset similarity.
In an optional embodiment of the present invention, the third obtaining module is specifically configured to:
and scanning the interaction requirement document, acquiring an operable object with the same identifier as the layout requirement document, and identifying the interaction operation of the operable object to obtain the interaction information of the target page.
The present invention also provides a computer apparatus comprising a memory for storing at least one instruction and a processor for executing the at least one instruction to implement the code generation method of any of the embodiments.
The present invention also provides a computer-readable storage medium storing at least one instruction that when executed by a processor implements the code generation method of any of the embodiments.
According to the technical scheme, the demand document of the target page is acquired, and the demand document comprises a layout demand document and an interaction demand document; acquiring page elements of the target page from the layout requirement document; converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document; acquiring interaction information of the target page from the interaction requirement document; and creating an interaction code of the target page in an active component associated with the android layout document according to the interaction information. Because the obtained android layout document contains the android page element codes converted from the page elements of the target page, and the active components associated with the android layout document contain the interactive codes expressing the interaction information of the target page, the android layout document and the active component target page associated with the android Zhuo Buju document are the android codes for realizing the target page. Therefore, the android codes can be generated without writing the android codes one by a user, and the purposes of shortening the code development time and improving the code development efficiency are achieved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a code generation method provided by an embodiment of the present invention;
FIG. 2 is a functional block diagram of a code generating apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a computer device implementing a code generation method according to a preferred embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
As shown in fig. 1, fig. 1 is a flowchart of a code generation method according to an embodiment of the present invention. The order of the steps in the flowchart may be changed and some steps may be omitted according to various needs.
S11, acquiring a requirement document of a target page, wherein the requirement document comprises a layout requirement document and an interaction requirement document.
The code generated by the embodiment of the invention is the program code of the android application. Specifically, a layout file of the android application and an active component of the android application may be included.
In this embodiment, the target page is a page corresponding to the code generated by the present invention. For example, if the target page is a landing page, the code of the landing page can be generated by the method of the present invention.
The requirement document can be information of overall planning of the target page. In particular, the requirements documents may include layout requirements documents and interaction requirements documents.
The layout requirement document may include layout information of the target page, for example, the layout information may be information of which elements (such as information of a button, a drop-down frame, a text box, etc.) included in the target page, background color of the page, etc., and the layout requirement document may be an html file, an xml file, etc. written by a markup language, etc.
The interaction requirement document can include interaction conditions of the target page, for example, which buttons in the target page can perform what interaction operation, and the interaction requirement document can be an html file or a javascript file or other file capable of storing interaction information.
S12: and acquiring page elements of the target page from the layout requirement document.
In this embodiment, the page element of the target page may be obtained by identifying the tag in the layout requirement document.
Specifically, the layout requirement document can be read, the labels and the attribute information of the labels contained in the layout requirement document can be obtained, and meanwhile, the information contained between the labels or in the labels can be obtained, namely the page elements of the target page.
In this embodiment, a layout description document is exemplified as an html file. In an html file, the tags have a specific authoring format, such as < div > </div > indicates a layer, where < div > indicates a start tag, < div > indicates an end tag, and the content between < div > and </div > is the content that the layer displays when the page is displayed. For another example, there is < div style= "color: #00ff00" >, where color defines background color information of this layer, that is, attribute information of the tag. Based on this, the page element obtained by the html file may be < div > representing the layer and background color information of the layer.
Optionally, in other embodiments of the present invention, the method further includes:
and if the page element of the target page cannot be acquired from the layout requirement document, outputting an error reminding message.
The error reminding message can remind the developer of the corresponding target page in an error log mode, so that the corresponding developer can quickly track the problems, and further the problems are solved.
For example, if the tag in the layout requirement document is a tag with irregular naming, the page element identified by the tag may not be identified, and an error alert message is output.
According to the embodiment, if the page elements cannot be obtained through the layout requirement document, an error reminding message can be output, so that a developer can quickly find out which page elements are not converted, and auxiliary information can be provided for the developer to manually process.
S13: and converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document.
The android page element code is a page element code applicable to an android program.
Specifically, the corresponding conversion relationship of what page element is read and converted into what android page element code can be predefined. After obtaining the page elements contained in the layout requirement document, the page elements of the target page can be converted into android page element codes of the target page according to the corresponding conversion relation.
For example, if < div > </div > is read, conversion is made to the corresponding < LinearLayout > </LinearLayout >, application is made in the android program, and contents between < div > </div > are added between < LinearLayout > </LinearLayout >.
The android layout document is an XML layout file for android program codes, and the android layout document can be a newly created file after page elements of the target page are converted into android page element codes of the target page.
For android programs, typically one page includes an XML layout file and a java code file. The XML layout file defines the layout of the page, and the java code defines the logical jump of the page. Specifically, the common XML layout document has an inherent format, so that the android layout document can be generated according to the template of the common XML layout document.
The method can quickly generate the XML layout file for the android program without manually writing the XML layout file for the android program, thereby shortening the development time and improving the development efficiency.
Preferably, the android layout document may be pre-created.
S14, acquiring the interaction information of the target page from the interaction requirement document.
In this embodiment, the interaction requirement document may include information about which ones of the available actions can take which jumps.
Therefore, the interaction information of the target page can be obtained from the interaction requirement document.
Optionally, the acquiring the interaction information of the target page from the interaction requirement document may include:
and scanning the interaction requirement document, acquiring an operable object with the same identifier as the layout requirement document, and identifying the interaction operation of the operable object to obtain the interaction information of the target page.
Wherein, whether the page element is an operable object can be identified by the type of the tag of the page element, for example, if < button type= "button" >, the tag represents a button, and thus the tag button is identified as the operable object.
Because the interaction requirement document contains the interaction information of the page elements, the same operable object as the identifier in the layout requirement document can be obtained from the interaction requirement document, and then the interaction operation of the operable object is identified (for example, clicking the button A and jumping to the first page, the interaction operation jumps to the first page; executing the button B and opening the m pages in a new window, etc.), so that the interaction information of the target page is obtained.
For example, for html code: < button onclick= "copy text ()" > text </button >), the html code is used to identify that after clicking the button, an operation is performed according to the function copy text (), i.e., the content defined by the function copy text (), i.e., 'onclick= "copy text ()"' indicates the interactive operation of the operable object.
And S15, creating the interaction code of the target page in an active component associated with the android layout document according to the interaction information.
The activity component may also be called activity, the activity is an application component in android, one page displayed by the android application may be called activity, one page Zhuo Ying is composed of a plurality of activities, and different pages are different activities. The user can interact with the android application through activity.
In this embodiment, the active component associated with the android layout document may be created after the interaction information of the target page is obtained from the interaction requirement document.
Preferably, the android layout document may also be pre-created.
For example, if the android layout document is a page_success.xml, in activity, the activity is associated with page_success.xml by setContentView (R.layout. Page_success), and an active component associated with the android Zhuo Buju document is obtained. It can be appreciated that if the android layout document to be associated is an xml file of other names, the parent_success in setContentView representing the file name is replaced with the xml file of other names.
Creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information may be: and generating an interactive function corresponding to the operable object in the active component associated with the android layout document according to the interactive operation of the operable object contained in the interactive information.
For example, if the operation performed is to open a homepage (Open HomePage in Current Window) in the current window when clicking the a button, a code of the following click event is created in activity:
after the button A is clicked, the homepage expressed by HomePage is opened.
Through the above steps, for one of the amperes Zhuo Yemian, the XML layout document representing the page and the activity associated with the XML layout document can be obtained, thereby obtaining the android code of the page. The android code can be generated quickly without writing the code by a user, and the development efficiency is improved.
Optionally, in other embodiments of the present invention, after the creating, according to the interaction information, the interaction code of the target page in the active component associated with the android layout document, the method further includes:
starting the movable component and receiving interactive operation of a preset operable object included in the movable component;
Acquiring an interaction result of the interaction operation;
judging whether the interaction result is an expected interaction result or not;
and if the interaction result is not the expected interaction result, outputting a first operation error prompt.
In this embodiment, after the android code is generated, the generated android code may be tested for interactive operation to detect the accuracy of the android code.
Wherein the preset operable object is an object having an interactive operation in the active component, such as a button, a text box, a selection button, etc.
The interaction may be click, double click, hover, etc.
The above-mentioned interactive result may be an operation performed after the preset operable object receives the interactive operation, for example, a page jump, a new window opening page, displaying a drop-down menu, etc.
The expected interaction result may be an interaction result generated when the generated code is operating correctly.
The output operation error prompt can be an error prompt output on an operation interface.
Through the method and the device, interaction functions contained in the generated android codes can be tested, feedback reminding is conducted on interactions which do not meet expectations, workload of developers is reduced, and development efficiency is improved.
Optionally, in other embodiments of the present invention, after the creating, according to the interaction information, the interaction code of the target page in the active component associated with the android layout document, the method further includes:
starting the movable component to display the target page;
acquiring a display picture from the target page and acquiring a page demand picture according to the layout demand document;
matching the display picture with the page demand picture;
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, outputting a second operation error prompt.
The display picture and the page demand picture may be corresponding pictures. Specifically, the display picture may be a panoramic picture taken from the target page, for example, a complete screenshot of the target page, and the acquired page demand picture may be an interface design drawing, that is, a display style corresponding to the designed target page; or the display picture can also be a part of pictures taken from the target page, for example, the picture of a certain button, and correspondingly, the acquired page requirement picture is also the picture when the button is designed.
The preset similarity can be preset according to needs, and the preset similarity is used for judging whether the similarity between the display picture and the page demand picture is lower or not. For example, the preset similarity is 80%.
The second operation error prompt may be to pop up a display frame in the operation interface, and the similarity matching result displayed in the pop up frame.
According to the method and the device, after the android codes are generated, a developer does not need to manually check and compare whether the page represented by the android codes is consistent with the page in design, matching is conducted through image comparison, and when the similarity is low, the fact that errors exist in the generated android codes is indicated, and reminding is conducted. When the developed pages are more, the generated codes can be rapidly checked through the embodiment, so that the labor consumption is reduced, the development efficiency is improved, and the development progress is accelerated.
Optionally, in other embodiments of the present invention, the method further includes:
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, marking and displaying the display range of the display picture in the target page.
For example, if the display picture is a button, the range included in the display picture is the display range of the button; or, if the display picture is a background picture, the range included in the display picture is the display range of the background picture.
Wherein the indicia display may be a highlighting color circled indicia or may be displayed with different transparency.
In this embodiment, when the similarity between the display picture and the page demand picture is lower than the preset similarity, the display range of the display picture is marked and displayed in the target page, so that a developer can intuitively understand the difference between the generated code and the page in design, which is favorable for quickly adjusting the generated code and improving the development efficiency.
The code generation method provided by the invention acquires the requirement document of the target page, wherein the requirement document comprises a layout requirement document and an interaction requirement document; acquiring page elements of the target page from the layout requirement document; converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document; acquiring interaction information of the target page from the interaction requirement document; and creating an interaction code of the target page in an active component associated with the android layout document according to the interaction information. Because the obtained android layout document contains the android page element codes converted from the page elements of the target page, and the active components associated with the android layout document contain the interactive codes expressing the interaction information of the target page, the android layout document and the active component target page associated with the android Zhuo Buju document are the android codes for realizing the target page. Therefore, the android codes can be generated without writing the android codes one by a user, and the purposes of shortening the code development time and improving the code development efficiency are achieved.
As shown in fig. 2, fig. 2 is a functional block diagram of a code generating apparatus according to an embodiment of the present invention. The code generating apparatus includes a first acquisition module 210, a second acquisition module 220, a first generation module 230, a third acquisition module 240, and a second generation module 250. The module referred to in the present invention refers to a series of computer program segments capable of being executed by a processor of a computer device and of accomplishing a fixed function, which are stored in a memory of the computer device. In the present embodiment, the functions of the respective modules will be described in detail in the following embodiments.
The first obtaining module 210 is configured to obtain a requirement document of the target page, where the requirement document includes a layout requirement document and an interaction requirement document.
The code generated by the embodiment of the invention is the program code of the android application. Specifically, a layout file of the android application and an active component of the android application may be included.
In this embodiment, the target page is a page corresponding to the code generated by the present invention. For example, if the target page is a landing page, the code of the landing page can be generated by the method of the present invention.
The requirement document can be information of overall planning of the target page. In particular, the requirements documents may include layout requirements documents and interaction requirements documents.
The layout requirement document may include layout information of the target page, for example, the layout information may be information of which elements (such as information of a button, a drop-down frame, a text box, etc.) included in the target page, background color of the page, etc., and the layout requirement document may be an html file, an xml file, etc. written by a markup language, etc.
The interaction requirement document can include interaction conditions of the target page, for example, which buttons in the target page can perform what interaction operation, and the interaction requirement document can be an html file or a javascript file or other file capable of storing interaction information.
And a second obtaining module 220, configured to obtain a page element of the target page from the layout requirement document.
In this embodiment, the page element of the target page may be obtained by identifying the tag in the layout requirement document.
Specifically, the layout requirement document can be read, the labels and the attribute information of the labels contained in the layout requirement document can be obtained, and meanwhile, the information contained between the labels or in the labels can be obtained, namely the page elements of the target page.
In this embodiment, a layout description document is exemplified as an html file. In an html file, the tags have a specific authoring format, such as < div > </div > indicates a layer, where < div > indicates a start tag, < div > indicates an end tag, and the content between < div > and </div > is the content that the layer displays when the page is displayed. For another example, there is < div style= "color: #00ff00" >, where color defines background color information of this layer, that is, attribute information of the tag. Based on this, the page element obtained by the html file may be < div > representing the layer and background color information of the layer.
Optionally, in other embodiments of the present invention, the apparatus further includes a reminder module.
And the reminding module is used for outputting an error reminding message if the page element of the target page cannot be acquired from the layout requirement document.
The error reminding message can remind the developer of the corresponding target page in an error log mode, so that the corresponding developer can quickly track the problems, and further the problems are solved.
For example, if the tag in the layout requirement document is a tag with irregular naming, the page element identified by the tag may not be identified, and an error alert message is output.
According to the embodiment, if the page elements cannot be obtained through the layout requirement document, an error reminding message can be output, so that a developer can quickly find out which page elements are not converted, and auxiliary information can be provided for the developer to manually process.
The first generation module 230 is configured to convert the page element of the target page into an android page element code of the target page, and add the android page element code to an android layout document.
The android page element code is a page element code applicable to an android program.
Specifically, the corresponding conversion relationship of what page element is read and converted into what android page element code can be predefined. After obtaining the page elements contained in the layout requirement document, the page elements of the target page can be converted into android page element codes of the target page according to the corresponding conversion relation.
For example, if < div > </div > is read, conversion is made to the corresponding < LinearLayout > </LinearLayout >, application is made in the android program, and contents between < div > </div > are added between < LinearLayout > </LinearLayout >.
The android layout document is an XML layout file for android program codes, and the android layout document can be a newly created file after page elements of the target page are converted into android page element codes of the target page.
For android programs, typically one page includes an XML layout file and a java code file. The XML layout file defines the layout of the page, and the java code defines the logical jump of the page. Specifically, the common XML layout document has an inherent format, so that the android layout document can be generated according to the template of the common XML layout document.
The method can quickly generate the XML layout file for the android program without manually writing the XML layout file for the android program, thereby shortening the development time and improving the development efficiency.
Preferably, the android layout document may be pre-created.
And a third obtaining module 240, configured to obtain the interaction information of the target page from the interaction requirement document.
In this embodiment, the interaction requirement document may include information about which ones of the available actions can take which jumps.
Therefore, the interaction information of the target page can be obtained from the interaction requirement document.
Optionally, the third obtaining module 240 is specifically configured to:
and scanning the interaction requirement document, acquiring an operable object with the same identifier as the layout requirement document, and identifying the interaction operation of the operable object to obtain the interaction information of the target page.
Wherein, whether the page element is an operable object can be identified by the type of the tag of the page element, for example, if < button type= "button" >, the tag represents a button, and thus the tag button is identified as the operable object.
Because the interaction requirement document contains the interaction information of the page elements, the same operable object as the identifier in the layout requirement document can be obtained from the interaction requirement document, and then the interaction operation of the operable object is identified (for example, clicking the button A and jumping to the first page, the interaction operation jumps to the first page; executing the button B and opening the m pages in a new window, etc.), so that the interaction information of the target page is obtained.
For example, for html code: < button onclick= "copy text ()" > text </button >), the html code is used to identify that after clicking the button, an operation is performed according to the function copy text (), i.e., the content defined by the function copy text (), i.e., 'onclick= "copy text ()"' indicates the interactive operation of the operable object.
And the second generation module 250 is used for creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information.
The activity component may also be called activity, the activity is an application component in android, one page displayed by the android application may be called activity, one page Zhuo Ying is composed of a plurality of activities, and different pages are different activities. The user can interact with the android application through activity.
In this embodiment, the active component associated with the android layout document may be created after the interaction information of the target page is obtained from the interaction requirement document.
Preferably, the android layout document may also be pre-created.
For example, if the android layout document is a page_success.xml, in activity, the activity is associated with page_success.xml by setContentView (R.layout. Page_success), and an active component associated with the android Zhuo Buju document is obtained. It can be appreciated that if the android layout document to be associated is an xml file of other names, the parent_success in setContentView representing the file name is replaced with the xml file of other names.
Creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information may be: and generating an interactive function corresponding to the operable object in the active component associated with the android layout document according to the interactive operation of the operable object contained in the interactive information.
For example, if the operation performed is to open a homepage (Open HomePage in Current Window) in the current window when clicking the a button, a code of the following click event is created in activity:
After the button A is clicked, the homepage expressed by HomePage is opened.
Through the above modules, for one ampere Zhuo Yemian, the XML layout document representing the page and the activity associated with the XML layout document can be obtained, thereby obtaining the android code of the page. The android code can be generated quickly without writing the code by a user, and the development efficiency is improved.
Optionally, in other embodiments of the present invention, the apparatus further includes a first verification module, where the first verification module is configured to:
after the interactive code of the target page is created in the active component associated with the android layout document according to the interactive information, starting the active component, and receiving interactive operation of a preset operable object included in the active component;
acquiring an interaction result of the interaction operation;
judging whether the interaction result is an expected interaction result or not;
and if the interaction result is not the expected interaction result, outputting a first operation error prompt.
In this embodiment, after the android code is generated, the generated android code may be tested for interactive operation to detect the accuracy of the android code.
Wherein the preset operable object is an object having an interactive operation in the active component, such as a button, a text box, a selection button, etc.
The interaction may be click, double click, hover, etc.
The above-mentioned interactive result may be an operation performed after the preset operable object receives the interactive operation, for example, a page jump, a new window opening page, displaying a drop-down menu, etc.
The expected interaction result may be an interaction result generated when the generated code is operating correctly.
The output operation error prompt can be an error prompt output on an operation interface.
Through the method and the device, interaction functions contained in the generated android codes can be tested, feedback reminding is conducted on interactions which do not meet expectations, workload of developers is reduced, and development efficiency is improved.
Optionally, in other embodiments of the present invention, the apparatus further includes a second checking module, where the second checking module is configured to:
after the interactive codes of the target pages are created in the active components associated with the android layout document according to the interactive information, starting the active components to display the target pages;
Acquiring a display picture from the target page and acquiring a page demand picture according to the layout demand document;
matching the display picture with the page demand picture;
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, outputting a second operation error prompt.
The display picture and the page demand picture may be corresponding pictures. Specifically, the display picture may be a panoramic picture taken from the target page, for example, a complete screenshot of the target page, and the acquired page demand picture may be an interface design drawing, that is, a display style corresponding to the designed target page; or the display picture can also be a part of pictures taken from the target page, for example, the picture of a certain button, and correspondingly, the acquired page requirement picture is also the picture when the button is designed.
The preset similarity can be preset according to needs, and the preset similarity is used for judging whether the similarity between the display picture and the page demand picture is lower or not. For example, the preset similarity is 80%.
The second operation error prompt may be to pop up a display frame in the operation interface, and the similarity matching result displayed in the pop up frame.
According to the method and the device, after the android codes are generated, a developer does not need to manually check and compare whether the page represented by the android codes is consistent with the page in design, matching is conducted through image comparison, and when the similarity is low, the fact that errors exist in the generated android codes is indicated, and reminding is conducted. When the developed pages are more, the generated codes can be rapidly checked through the embodiment, so that the labor consumption is reduced, the development efficiency is improved, and the development progress is accelerated.
Optionally, in other embodiments of the present invention, the apparatus further includes a marker display module.
And the marking display module is used for marking and displaying the display range of the display picture in the target page if the similarity between the display picture and the page demand picture is lower than the preset similarity.
For example, if the display picture is a button, the range included in the display picture is the display range of the button; or, if the display picture is a background picture, the range included in the display picture is the display range of the background picture.
Wherein the indicia display may be a highlighting color circled indicia or may be displayed with different transparency.
In this embodiment, when the similarity between the display picture and the page demand picture is lower than the preset similarity, the display range of the display picture is marked and displayed in the target page, so that a developer can intuitively understand the difference between the generated code and the page in design, which is favorable for quickly adjusting the generated code and improving the development efficiency.
The code generating device provided by the invention acquires a demand document of a target page through a first acquisition module, wherein the demand document comprises a layout demand document and an interaction demand document; a second acquisition module acquires page elements of the target page from the layout requirement document; the first generation module converts the page elements of the target page into android page element codes of the target page, and adds the android page element codes into an android layout document; the third acquisition module acquires the interaction information of the target page from the interaction requirement document; and the second generation module creates the interaction code of the target page in an active component associated with the android layout document according to the interaction information. Because the obtained android layout document contains the android page element codes converted from the page elements of the target page, and the active components associated with the android layout document contain the interactive codes expressing the interaction information of the target page, the android layout document and the active component target page associated with the android Zhuo Buju document are the android codes for realizing the target page. Therefore, the android codes can be generated without writing the android codes one by a user, and the purposes of shortening the code development time and improving the code development efficiency are achieved.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform some of the steps of the methods described in the various embodiments of the invention.
As shown in fig. 3, fig. 3 is a schematic structural diagram of a computer device implementing a code generation method according to a preferred embodiment of the present invention. The computer means comprise at least one transmitting means 31, at least one memory 32, at least one processor 33, at least one receiving means 34 and at least one communication bus. Wherein the communication bus is used to enable connection communication between these components.
The computer apparatus is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and its hardware includes, but is not limited to, a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a programmable gate array (Field-Programmable Gate Array, FPGA), a digital processor (Digital Signal Processor, DSP), an embedded device, and the like. The computer apparatus may also include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network server, a server group composed of a plurality of network servers, or a Cloud based Cloud Computing (Cloud Computing) composed of a large number of hosts or network servers, wherein Cloud Computing is one of distributed Computing, and is a super virtual computer composed of a group of loosely coupled computer sets.
The computer device may be, but is not limited to, any electronic product that can perform man-machine interaction with a user through a keyboard, a touch pad, or a voice control device, for example, a terminal such as a tablet computer, a smart phone, or a monitoring device.
The network in which the computer device is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
The receiving means 34 and the transmitting means 31 may be wired transmission ports, or may be wireless devices, for example, including antenna means for performing data communication with other devices.
The memory 32 is used for storing program codes. The Memory 32 may be a circuit with a Memory function, such as a RAM (Random-Access Memory), a FIFO (First In First Out, first-in first-out Memory), etc., which is not in physical form in the integrated circuit. Alternatively, the memory 32 may be a physical memory, such as a memory bank, a TF Card (Trans-flash Card), a smart media Card (smart media Card), a secure digital Card (secure digital Card), a flash memory Card (flash Card), or the like.
The processor 33 may comprise one or more microprocessors, digital processors. The processor 33 may call program code stored in the memory 32 to perform the relevant functions. For example, each of the units described in fig. 3 is a program code stored in the memory 32 and executed by the processor 33 to implement a code generation method. The processor 33 is also called a central processing Unit (CPU, central Processing Unit), which is a very large scale integrated circuit and is an operation Core (Core) and a Control Unit (Control Unit).
In the several embodiments provided in the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention 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 can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (8)

1. A code generation method, the method comprising:
acquiring a demand document of a target page, wherein the demand document comprises a layout demand document and an interaction demand document;
acquiring page elements of the target page from the layout requirement document;
converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document;
the method for acquiring the interaction information of the target page from the interaction requirement document comprises the following steps: scanning the interaction requirement document to acquire an operable object with the same identifier as the layout requirement document;
creating the interaction code of the target page in an active component associated with the android layout document according to the interaction information, wherein the interaction code comprises the following steps: generating an interactive function corresponding to the operable object in an active component associated with the android layout document according to the interactive operation of the operable object contained in the interactive information;
After the interactive code is created, starting the movable component, receiving interactive operation of a preset operable object included in the movable component, acquiring an interactive result of the received interactive operation of the preset operable object, judging whether the interactive result is an expected interactive result, and outputting a first operation error reminder if the interactive result is not the expected interactive result;
and starting the movable component to display the target page, acquiring a display picture from the target page, acquiring a page demand picture according to the layout demand document, matching the display picture with the page demand picture, and outputting a second operation error prompt if the similarity between the display picture and the page demand picture is lower than a preset similarity.
2. The method of claim 1, wherein the android layout document and the active component associated with the android layout document are pre-created.
3. The method of claim 1, wherein the method further comprises:
and if the page element of the target page cannot be acquired from the layout requirement document, outputting an error reminding message.
4. The method of claim 1, wherein the method further comprises:
and if the similarity between the display picture and the page demand picture is lower than the preset similarity, marking and displaying the display range of the display picture in the target page.
5. The method of claim 1, wherein the obtaining interaction information for the target page from the interaction requirement document further comprises:
and identifying the interactive operation of the operable object to obtain the interactive information of the target page.
6. A code generating apparatus, the apparatus comprising:
the system comprises a first acquisition module, a second acquisition module and a first processing module, wherein the first acquisition module is used for acquiring a demand document of a target page, and the demand document comprises a layout demand document and an interaction demand document;
the second acquisition module is used for acquiring page elements of the target page from the layout requirement document;
the first generation module is used for converting the page element of the target page into an android page element code of the target page, and adding the android page element code into an android layout document;
the third obtaining module is configured to obtain the interaction information of the target page from the interaction requirement document, and includes: scanning the interaction requirement document to acquire an operable object with the same identifier as the layout requirement document;
The second generating module is used for creating the interaction code of the target page in the active component associated with the android layout document according to the interaction information, and comprises the following steps: generating an interactive function corresponding to the operable object in an active component associated with the android layout document according to the interactive operation of the operable object contained in the interactive information;
the first verification module is used for starting the movable component after the interactive code is created, receiving the interactive operation of the preset operable object included in the movable component, acquiring the received interactive result of the interactive operation of the preset operable object, judging whether the interactive result is an expected interactive result, and outputting a first running error reminder if the interactive result is not the expected interactive result;
the second checking module is used for starting the movable assembly to display the target page, acquiring a display picture from the target page, acquiring a page demand picture according to the layout demand document, matching the display picture with the page demand picture, and outputting a second running error prompt if the similarity of the display picture and the page demand picture is lower than a preset similarity.
7. A computer apparatus comprising a memory for storing at least one instruction and a processor for executing the at least one instruction to implement the code generation method of any of claims 1 to 5.
8. A computer-readable storage medium having stored thereon computer instructions, characterized by: the computer instructions, when executed by a processor, implement the code generation method of any of claims 1 to 5.
CN201811270329.4A 2018-10-29 2018-10-29 Code generation method, device, computer device and storage medium Active CN109634579B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811270329.4A CN109634579B (en) 2018-10-29 2018-10-29 Code generation method, device, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811270329.4A CN109634579B (en) 2018-10-29 2018-10-29 Code generation method, device, computer device and storage medium

Publications (2)

Publication Number Publication Date
CN109634579A CN109634579A (en) 2019-04-16
CN109634579B true CN109634579B (en) 2023-08-22

Family

ID=66066777

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811270329.4A Active CN109634579B (en) 2018-10-29 2018-10-29 Code generation method, device, computer device and storage medium

Country Status (1)

Country Link
CN (1) CN109634579B (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
CN111208998B (en) * 2019-12-27 2024-03-05 深圳力维智联技术有限公司 Method, device and storage medium for automatic layout of data visualization large screen
CN111736812A (en) * 2020-06-16 2020-10-02 北京三快在线科技有限公司 Document code execution method and device, computer equipment and storage medium
CN112287255B (en) * 2020-07-13 2024-02-09 上海柯林布瑞信息技术有限公司 Page construction method and device, computing equipment and computer readable storage medium
CN115373683A (en) * 2022-08-22 2022-11-22 北京字跳网络技术有限公司 Page display method, source code compiling method and related equipment
CN118133775B (en) * 2024-05-08 2024-09-13 工业富联(杭州)数据科技有限公司 Document generation method, electronic device and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007007017A1 (en) * 2005-07-08 2007-01-18 Corizon Limited Method and apparatus for user interface modification
WO2007056807A1 (en) * 2005-11-18 2007-05-24 Robert Arthur Crewdson Computer software development system and method
WO2013106947A1 (en) * 2012-01-18 2013-07-25 Metrologic Instruments, Inc. Web-based scan-task enabled system. and method of and apparatus for developing and deploying the same on a client-server network
CN103605527A (en) * 2013-12-06 2014-02-26 普元信息技术股份有限公司 System and method for realizing cloud computing application interface integration and unified style display
CN104317587A (en) * 2014-10-22 2015-01-28 中国人民解放军国防科学技术大学 Automatic android mobile device oriented application generation method
CN105094872A (en) * 2014-05-16 2015-11-25 腾讯科技(北京)有限公司 Method and apparatus for displaying webpage application
CN105739969A (en) * 2016-01-21 2016-07-06 南京南瑞集团公司 Input tags-based application method of custom tags
CN106371844A (en) * 2016-08-31 2017-02-01 北京奇艺世纪科技有限公司 Method and system for presenting webpage by native user interface assembly
CN107247691A (en) * 2017-05-24 2017-10-13 腾讯科技(深圳)有限公司 A kind of display methods of text message, device, mobile terminal and storage medium
CN107577509A (en) * 2017-08-28 2018-01-12 深圳市金立通信设备有限公司 A kind of method, terminal and computer-readable recording medium for loading application interface
CN107992301A (en) * 2017-11-27 2018-05-04 腾讯科技(上海)有限公司 User interface implementation method, client and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10268460B2 (en) * 2017-01-25 2019-04-23 Walmart Apollo, Llc Systems, method, and non-transitory computer-readable storage media for generating code for displaying a webpage

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007007017A1 (en) * 2005-07-08 2007-01-18 Corizon Limited Method and apparatus for user interface modification
WO2007056807A1 (en) * 2005-11-18 2007-05-24 Robert Arthur Crewdson Computer software development system and method
WO2013106947A1 (en) * 2012-01-18 2013-07-25 Metrologic Instruments, Inc. Web-based scan-task enabled system. and method of and apparatus for developing and deploying the same on a client-server network
CN103605527A (en) * 2013-12-06 2014-02-26 普元信息技术股份有限公司 System and method for realizing cloud computing application interface integration and unified style display
CN105094872A (en) * 2014-05-16 2015-11-25 腾讯科技(北京)有限公司 Method and apparatus for displaying webpage application
CN104317587A (en) * 2014-10-22 2015-01-28 中国人民解放军国防科学技术大学 Automatic android mobile device oriented application generation method
CN105739969A (en) * 2016-01-21 2016-07-06 南京南瑞集团公司 Input tags-based application method of custom tags
CN106371844A (en) * 2016-08-31 2017-02-01 北京奇艺世纪科技有限公司 Method and system for presenting webpage by native user interface assembly
CN107247691A (en) * 2017-05-24 2017-10-13 腾讯科技(深圳)有限公司 A kind of display methods of text message, device, mobile terminal and storage medium
CN107577509A (en) * 2017-08-28 2018-01-12 深圳市金立通信设备有限公司 A kind of method, terminal and computer-readable recording medium for loading application interface
CN107992301A (en) * 2017-11-27 2018-05-04 腾讯科技(上海)有限公司 User interface implementation method, client and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
互联网电视运营管理系统的设计与实现;代晓宇;《中国优秀硕士学位论文全文数据库信息科技辑》(第6期);I138-306 *

Also Published As

Publication number Publication date
CN109634579A (en) 2019-04-16

Similar Documents

Publication Publication Date Title
CN109634579B (en) Code generation method, device, computer device and storage medium
US20220067268A1 (en) Systems and methods for remote dashboard image generation
CN106991154B (en) Webpage rendering method and device, terminal and server
CN110347953B (en) Page generation method, page generation device, computer equipment and storage medium
CN111639287A (en) Page processing method and device, terminal equipment and readable storage medium
US10419568B2 (en) Manipulation of browser DOM on server
US20150363368A1 (en) Transforming HTML Forms into Mobile Native Forms
CN110533464B (en) Advertisement monitoring method, device and system and computing equipment
US11550990B2 (en) Machine first approach for identifying accessibility, non-compliances, remediation techniques and fixing at run-time
CN113031946A (en) Method and device for rendering page component
CN113158101A (en) Visual page rendering method, device, equipment and storage medium
CN111651966A (en) Data report file generation method and device and electronic equipment
CN115525292A (en) Low code development method and device, readable storage medium and electronic equipment
CN111562911B (en) Webpage editing method and device and storage medium
KR20200034660A (en) Facilitated user interaction
CN110795651A (en) Method and device for saving front-end data and electronic equipment
US20160275063A1 (en) Transforming html forms into mobile native forms
CN111832254B (en) Drawing annotation display processing method and device
US9104573B1 (en) Providing relevant diagnostic information using ontology rules
US11126410B2 (en) Method and apparatus for building pages, apparatus and non-volatile computer storage medium
CN116774973A (en) Data rendering method, device, computer equipment and storage medium
CN116432624A (en) Micro-service API document generation method, device, equipment and storage medium
CN114579461A (en) Browser compatibility detection method and related equipment
CN113849257A (en) Page processing method, device, medium and electronic equipment
CN111913703B (en) Object editing method, device, electronic equipment and readable storage medium

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