CN110780874B - Method and device for generating information - Google Patents

Method and device for generating information Download PDF

Info

Publication number
CN110780874B
CN110780874B CN201911023348.1A CN201911023348A CN110780874B CN 110780874 B CN110780874 B CN 110780874B CN 201911023348 A CN201911023348 A CN 201911023348A CN 110780874 B CN110780874 B CN 110780874B
Authority
CN
China
Prior art keywords
user interface
interface component
source code
target
identification
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
CN201911023348.1A
Other languages
Chinese (zh)
Other versions
CN110780874A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201911023348.1A priority Critical patent/CN110780874B/en
Publication of CN110780874A publication Critical patent/CN110780874A/en
Application granted granted Critical
Publication of CN110780874B publication Critical patent/CN110780874B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration 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)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The embodiment of the disclosure discloses a method and a device for generating information. One embodiment of the method comprises the following steps: analyzing templates and scripts included in the received user interface components to obtain the description information of the user interface components; generating a Markdown document according to the description information; acquiring examples and example source codes of the user interface components; and writing the example tag character string established based on the example and the example source code into the Markdown document to obtain an explanation document aiming at the user interface component. The embodiment realizes the automatic generation of the UI component description document and improves the information generation efficiency. At the same time, the generated description document can realize the rendering of the examples and the display of the example source codes.

Description

Method and device for generating information
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a method and a device for generating information.
Background
With the development of front-end technology, front-end assembly development has also advanced greatly. With the implementation of a set of UI (User Interface) component libraries, it is generally necessary to provide a description document of each UI component in the UI component library, so that a developer can quickly implement a service function of a front-end page based on the UI component library. In addition, if the explanation document of the UI component can provide the example rendering and the corresponding source code related to the UI component for a developer to read, the development efficiency can be greatly improved. At this stage, a description document of the UI component is typically generated by means of manual writing. However, the means of writing is not only costly and inefficient, but may also suffer from non-uniform style due to the multiple people and writing.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for generating information.
In a first aspect, embodiments of the present disclosure provide a method for generating information, the method comprising: analyzing templates and scripts included in the received user interface components to obtain the description information of the user interface components; generating a Markdown document according to the description information; acquiring examples and example source codes of the user interface components; and writing the example tag character string established based on the example and the example source code into the Markdown document to obtain an explanation document aiming at the user interface component.
In some embodiments, the obtaining the example and the example source code of the user interface component includes: determining target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identification of the user interface component, wherein the target configuration information comprises a target example, and the target example comprises an example source code identification; according to the example source code identification, acquiring target example source codes from a preset example source code set; and taking the target examples and the target example source codes as examples and example source codes corresponding to the user interface component.
In some embodiments, the configuration information contained in the configuration file includes an example identifier; and determining target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identification of the user interface component, wherein the target configuration information comprises: determining whether the configuration file comprises configuration information of which the example identification is matched with the identification of the user interface component; responsive to determining to include, determining configuration information in the configuration file that matches the identification of the user interface component as target configuration information.
In some embodiments, the parsing the templates and scripts included in the received user interface component to obtain the description information of the user interface component includes: analyzing the template and the script into an abstract syntax tree; and acquiring the description information of the user interface component based on the abstract syntax tree.
In some embodiments, the above examples include at least one sub-example for demonstrating the state of the above user interface components in different scenarios.
In a second aspect, embodiments of the present disclosure provide an apparatus for generating information, the apparatus comprising: the analysis unit is configured to analyze the templates and the scripts included in the received user interface components to obtain the description information of the user interface components; a generation unit configured to generate a Markdown document based on the above description information; an acquisition unit configured to acquire the example of the user interface component and the example source code; and a writing unit configured to write the example tag character string established based on the example and the example source code into the Markdown document to obtain an explanation document for the user interface component.
In some embodiments, the acquiring unit includes: a first determining unit configured to determine target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identification of the user interface component, wherein the target configuration information comprises a target example, and the target example comprises an example source code identification; a source code obtaining unit configured to obtain target example source codes from a preset example source code set according to the example source code identification; and the second determining unit is configured to take the target example and the target example source code as the example and the example source code corresponding to the user interface component.
In some embodiments, the configuration information contained in the configuration file includes an example identifier; and the first determination unit is further configured to: determining whether the configuration file comprises configuration information of which the example identification is matched with the identification of the user interface component; responsive to determining to include, determining configuration information in the configuration file that matches the identification of the user interface component as target configuration information.
In some embodiments, the parsing unit is further configured to: analyzing the template and the script into an abstract syntax tree; and acquiring the description information of the user interface component based on the abstract syntax tree.
In some embodiments, the above examples include at least one sub-example for demonstrating the state of the above user interface components in different scenarios.
In a third aspect, embodiments of the present disclosure provide an apparatus comprising: one or more processors; and a storage device having one or more programs stored thereon, which when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a method as described in any of the implementations of the first aspect.
The method and the device for generating information provided by the embodiment of the disclosure firstly analyze templates and scripts included in the received user interface component to obtain the description information of the user interface component, and then generate a Markdown document according to the obtained description information. Then, examples of user interface components and example source code are obtained. Finally, the example tag string and the example source code established based on the examples are written into the Markdown document, so that the description document for the user interface component is obtained. The automatic generation of the UI component description document is realized, and the information generation efficiency is improved. At the same time, the generated description document can realize the rendering of the examples and the display of the example source codes.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
FIG. 2 is a flow chart of one embodiment of a method for generating information according to the present disclosure;
FIG. 3 is a schematic diagram of the composition of a Vue UI component;
FIG. 4 is an exemplary diagram of a portion of the content of a Markdown document generated based on description information of a button assembly, taking the button assembly as an example;
FIG. 5 is a schematic illustration of one application scenario of a method for generating information according to the present disclosure;
FIG. 6 is a flow chart of yet another embodiment of a method for generating information according to the present disclosure;
FIG. 7 is a schematic structural diagram of one embodiment of an apparatus for generating information according to the present disclosure;
fig. 8 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which a method for generating information or an apparatus for generating information of embodiments of the present disclosure may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting information processing, including but not limited to smart phones, tablet computers, laptop and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for information displayed on the terminal devices 101, 102, 103. The background server may analyze and/or the like the received data such as the user interface component and feed back the processing result (e.g., the description document) to the terminal devices 101, 102, 103.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster formed by a plurality of servers, or as a single server. When server 105 is software, it may be implemented as a plurality of software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that, the method for generating information provided by the embodiment of the present disclosure may be performed by the terminal devices 101, 102, 103, or may be performed by the server 105. Accordingly, the means for generating information may be provided in the terminal devices 101, 102, 103 or in the server 105. And are not limited herein.
With continued reference to fig. 2, a flow 200 of one embodiment of a method for generating information according to the present disclosure is shown. The method for generating information comprises the following steps:
and step 201, analyzing the template and the script included in the received user interface component to obtain the description information of the user interface component.
In the present embodiment, an execution subject of the method for generating information (e.g., the terminal devices 101, 102, 103 or the server 105 shown in fig. 1) may receive a UI (User Interface) component. By way of example, a UI component herein may refer to a UI component built under a Vue framework, which may also be referred to as a Vue UI component. Vue is a set of progressive JavaScript frames used to build a user interface. As shown in fig. 3, in general, the composition of the Vue UI component may include templates (templates), scripts (scripts), styles (styles), and the like. Various information can be defined in the three parts according to actual needs. For example, slot (slot) information may be defined in a template, and attribute (tips), data (data), events (events), methods (methods), etc. information may be defined in a script. In this way, the execution body can parse the templates and scripts of the UI component, thereby obtaining the description information of the UI component. By way of example, specification information for a UI component may include, but is not limited to, attribute information, events, methods, annotation specifications, slot information, and the like.
In some alternative implementations of the present embodiment, the foregoing step 201 may specifically be performed as follows:
first, templates and scripts are parsed into abstract syntax trees.
In this implementation, the execution body may parse templates and scripts of the user interface component into abstract syntax trees in various ways. As an example, the execution body may parse the template into an abstract syntax tree using a Vue-template-compiler module in Vue (Abstract Syntax Tree, AST). Here, an abstract Syntax tree (Abstract Syntax Tree, AST), or simply Syntax tree (syncax tree), is an abstract representation of the source code Syntax structure. It represents the syntax structure of a programming language in the form of a tree, each node on the tree representing a structure in the source code.
Then, based on the abstract syntax tree, description information of the user interface component is obtained.
In this implementation, the execution body may obtain the description information of the user interface component based on parsing to obtain the abstract syntax tree. In particular, the execution body may traverse the abstract syntax tree to obtain specification information for the user interface component.
Step 202, generating a Markdown document according to the description information.
In this embodiment, the execution body may generate a Markdown document according to the description information of the UI component obtained in step 201. Specifically, the execution body may edit the description information obtained in step 201 according to the Markdown document specification, thereby obtaining the Markdown document. Here, markdown is a markup language that can be written using a general text editor, which can give a certain format to general text contents through a simple markup syntax. By way of example, FIG. 4 illustrates a portion of the contents of a MarkDown document generated based on the description information of a Button component. It should be noted that, the information of properties, events, etc. contained in the Markdown document is merely illustrative, and is not a limitation on the content contained in the Markdown document.
Step 203, obtaining an example of a user interface component and example source code.
In the present embodiment, an instance (demo) of the UI component and an instance source code may be stored in advance inside the execution body. Here, examples may refer to examples that enable rendering of presentations. The example source code may be source code corresponding to the indication. The execution body may obtain examples of UI components and example source code in various ways. For example, for facilitating the acquisition, the example and the example source code corresponding to a UI component may be stored according to the UI component identifier of the UI component, for example, the name of the example and the example source code corresponding to the UI component may be the same as the UI component identifier. In this way, the execution body may obtain the example and the example source code corresponding to the UI component according to the UI component identifier of the UI component. Here, UI component identification may be used to uniquely identify one UI component. By way of example, the UI component identification may be a name, title, etc. of the UI component.
In some optional implementations of this embodiment, the examples may include at least one sub-example, where the at least one sub-example may be used to demonstrate the state of the user interface component in different scenarios. Taking the Button component as an example, the corresponding example titled Button component may include a number of sub-examples titled "basic usage", "disabled state", "text Button", "icon Button", "Button size", "load Button", and so on. Each sub-example includes a code for indicating a name of an example source code corresponding to the sub-example, a title for indicating a title of the sub-example, a description for indicating a scene to which the sub-example is applied, and the like. To illustrate a number of sub-examples of the Button component, the following supplements the corresponding code.
Figure BDA0002247901160000071
Figure BDA0002247901160000081
It should be noted that the above code is merely exemplary and not limiting of the Button component sub-examples.
Step 204, writing the example tag character string and the example source code established based on the example into the Markdown document to obtain the description document for the user interface component.
In this embodiment, the execution subject may first build an example tag string from the example obtained in step 203. As an example, the execution body may parse the obtained examples according to a preset method, thereby obtaining required example data, and perform string concatenation on the example data, thereby establishing an example tag string. As an example, the above-mentioned preset method may be set according to actual needs. Thereafter, the execution body may write the above-described example tag string and example source code to the Markdown document obtained in step 202, thereby obtaining an explanation document for the above-described user interface component. Here, the document is explained as a Markdown format document. In practice, since the description document is a Markdown format document, when a developer views the description document, the rendered example and the example source code of the example can be seen. Thus, the development efficiency of the developer can be greatly improved.
With continued reference to fig. 5, fig. 5 is a schematic diagram of an application scenario of the method for generating information according to the present embodiment. In the application scenario of fig. 5, the server 501 may first parse the templates and scripts included in the UI components in the received UI component library 502 to obtain description information of the UI components. Thereafter, a Markdown document 503 may be generated from the description information of the UI component. Then, the example and example source code of the UI component is obtained. Finally, the example tag character string and the example source code established based on the examples are written into the Markdown document to obtain the explanation document for the UI component.
The method provided by the embodiment of the disclosure obtains the description information based on the template and the script of the analysis UI component to generate the MarkDown document, and writes the example tag character string and the example source code corresponding to the example of the UI component into the MarkDown document, thereby realizing the automatic generation of the UI component description document and improving the information generation efficiency. At the same time, the generated description document can realize the rendering of the examples and the display of the example source codes.
With further reference to fig. 6, a flow 600 of yet another embodiment of a method for generating information is shown. The flow 600 of the method for generating information comprises the steps of:
and step 601, analyzing the template and the script included in the received user interface component to obtain the description information of the user interface component.
In this embodiment, step 601 is similar to step 201 of the embodiment shown in fig. 2, and will not be described here again.
Step 602, generating a Markdown document according to the description information.
In this embodiment, step 602 is similar to step 202 of the embodiment shown in fig. 2, and will not be described here again.
Step 603, determining target configuration information from at least one piece of configuration information contained in the pre-established configuration file according to the identification of the user interface component.
In this embodiment, a configuration file may be pre-established in the execution body, and the configuration file may include at least one piece of configuration information. Here, the configuration information may be used to describe a correspondence between the user interface component and the instance, where the instance may include a variety of information, such as a name, description, instance source code identification, and so forth. Here, the example source code identification may be used to uniquely identify the source code to which the example corresponds. In practice, the source codes of all examples may be stored in a certain location, so that the execution body may obtain, from the example source code identifier included in a certain example, the example source code corresponding to the example to the location.
In this way, the execution body may determine target configuration information from at least one piece of configuration information contained in the configuration file according to the identification of the user interface component, where the target configuration information may include a target instance, and the target instance may include an instance source code identification.
In some optional implementations of this embodiment, the configuration information included in the configuration file may include an example identifier. The above step 603 may be specifically performed as follows:
first, it is determined whether configuration information is included in the configuration file that matches the identification of the user interface component with the example identification.
In this implementation, the execution body may determine whether the configuration file includes configuration information in which the instance identifier matches (e.g., is the same as) the identifier of the user interface component.
Then, responsive to determining to include, determining configuration information in the configuration file that matches the identification of the user interface component as target configuration information.
In this implementation, if it is determined that the configuration file includes configuration information in which the example identification matches the identification of the user interface component, the execution subject may determine the configuration information in the configuration file in which the example identification matches the identification of the user interface component as the target configuration information.
Step 604, obtaining target example source codes from a preset example source code set according to the example source code identification.
In this embodiment, the execution body may obtain the target example source code from the preset example source code set according to the example source code identifier determined in step 604. Here, the example source code set may include example source code for corresponding examples of the user interface components.
Step 605, the target example and the target example source code are used as the corresponding examples and the example source code of the user interface component.
In this embodiment, the execution body may use the target instance included in the target configuration information determined in step 603 and the target instance source code acquired in step 604 as the instance and the instance source code corresponding to the user interface component.
Step 606, writing the example tag string and the example source code established based on the example into the Markdown document to obtain an explanation document for the user interface component.
In this embodiment, step 606 is similar to step 204 of the embodiment shown in fig. 2, and will not be described again.
As can be seen in fig. 6, the flow 600 of the method for generating information in this embodiment highlights the steps of obtaining example and example source code of a user interface component based on a configuration file, as compared to the corresponding embodiment of fig. 2. Therefore, the scheme described in the embodiment can realize flexible configuration of examples of the user interface components and example source codes by modifying the configuration file, so that the generated description document of the user interface components meets requirements better.
With further reference to fig. 7, as an implementation of the method shown in the foregoing figures, the present disclosure provides an embodiment of an apparatus for generating information, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied in various electronic devices.
As shown in fig. 7, the apparatus 700 for generating information of the present embodiment includes: an analysis unit 701, a generation unit 702, an acquisition unit 703, and a writing unit 704. The parsing unit 701 is configured to parse the template and the script included in the received user interface component to obtain description information of the user interface component; the generating unit 702 is configured to generate a Markdown document according to the above description information; the acquisition unit 703 is configured to acquire the example and the example source code of the user interface component described above; the writing unit 704 is configured to write the example tag string created based on the above example and the above example source code into the above Markdown document, resulting in an explanatory document for the above user interface component.
In this embodiment, the specific processes of the parsing unit 701, the generating unit 702, the acquiring unit 703 and the writing unit 704 of the apparatus 700 for generating information and the technical effects thereof may refer to the relevant descriptions of the steps 201, 202, 203 and 204 in the corresponding embodiment of fig. 2, and are not repeated herein.
In some optional implementations of the present embodiment, the acquiring unit 703 includes: a first determining unit (not shown in the figure) configured to determine target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identification of the user interface component, wherein the target configuration information includes a target example, and the target example includes an example source code identification; a source code obtaining unit (not shown in the figure) configured to obtain target example source codes from a preset example source code set according to the above-mentioned example source code identification; a second determining unit (not shown in the figure) configured to take the target example and the target example source code as the example and the example source code corresponding to the user interface component.
In some optional implementations of this embodiment, the configuration information included in the configuration file includes an example identifier; and the first determination unit is further configured to: determining whether the configuration file comprises configuration information of which the example identification is matched with the identification of the user interface component; responsive to determining to include, determining configuration information in the configuration file that matches the identification of the user interface component as target configuration information.
In some optional implementations of this embodiment, the parsing unit 701 is further configured to: analyzing the template and the script into an abstract syntax tree; and acquiring the description information of the user interface component based on the abstract syntax tree.
In some optional implementations of this embodiment, the examples include at least one sub-example for demonstrating the state of the user interface component in different scenarios.
Referring now to fig. 8, a schematic diagram of an electronic device (e.g., server or terminal device of fig. 1) 800 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device shown in fig. 8 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 8, the electronic device 800 may include a processing means (e.g., a central processor, a graphics processor, etc.) 801, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
In general, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, etc.; storage 808 including, for example, magnetic tape, hard disk, etc.; communication means 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 8 shows an electronic device 800 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 8 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 809, or installed from storage device 808, or installed from ROM 802. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 801.
It should be noted that, the computer readable medium according to the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In an embodiment of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in embodiments of the present disclosure, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: analyzing templates and scripts included in the received user interface components to obtain the description information of the user interface components; generating a Markdown document according to the description information; acquiring examples and example source codes of the user interface components; and writing the example tag character string established based on the example and the example source code into the Markdown document to obtain an explanation document aiming at the user interface component.
Computer program code for carrying out operations of embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes an parsing unit, a generating unit, an acquiring unit, and a writing unit. The names of these elements do not constitute a limitation on the element itself in some cases, for example, the acquisition element may also be described as "an element that acquires the example and example source code of the user interface component described above".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (10)

1. A method for generating information, comprising:
analyzing templates and scripts included in the received user interface components to obtain description information of the user interface components;
generating a Markdown document according to the description information;
acquiring examples and example source codes of the user interface component;
writing the example tag character string established based on the example and the example source code into the Markdown document to obtain an explanation document aiming at the user interface component;
wherein the obtaining the example and the example source code of the user interface component includes:
determining target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identification of the user interface component, wherein the target configuration information comprises a target example, and the target example comprises an example source code identification;
acquiring target example source codes from a preset example source code set according to the example source code identification;
and taking the target examples and the target example source codes as examples and example source codes corresponding to the user interface component.
2. The method of claim 1, wherein the configuration information contained in the configuration file includes an example identification; and
the determining, according to the identification of the user interface component, target configuration information from at least one piece of configuration information contained in a pre-established configuration file includes:
determining whether the configuration file comprises configuration information of which the example identification is matched with the identification of the user interface component;
responsive to determining to include, determining configuration information in the configuration file that matches an identification of the user interface component as target configuration information.
3. The method of claim 1, wherein parsing the templates and scripts included in the received user interface component to obtain the description information of the user interface component includes:
parsing the template and the script into an abstract syntax tree;
and acquiring the description information of the user interface component based on the abstract syntax tree.
4. The method of claim 1, wherein the examples include at least one sub-example for exposing a state of the user interface component in a different scenario.
5. An apparatus for generating information, comprising:
the analysis unit is configured to analyze templates and scripts included in the received user interface component to obtain the description information of the user interface component;
a generation unit configured to generate a Markdown document based on the specification information;
an acquisition unit configured to acquire an example of the user interface component and an example source code;
a writing unit configured to write the example tag character string established based on the example and the example source code into the Markdown document, resulting in an explanation document for the user interface component;
wherein the acquisition unit includes:
a first determining unit configured to determine target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to an identification of the user interface component, wherein the target configuration information comprises a target example, and the target example comprises an example source code identification;
a source code acquisition unit configured to acquire target example source codes from a preset example source code set according to the example source code identification;
and the second determining unit is configured to take the target example and the target example source code as the example and the example source code corresponding to the user interface component.
6. The apparatus of claim 5, wherein the configuration information contained in the configuration file comprises an example identification; and
the first determination unit is further configured to:
determining whether the configuration file comprises configuration information of which the example identification is matched with the identification of the user interface component;
responsive to determining to include, determining configuration information in the configuration file that matches an identification of the user interface component as target configuration information.
7. The apparatus of claim 5, wherein the parsing unit is further configured to:
parsing the template and the script into an abstract syntax tree;
and acquiring the description information of the user interface component based on the abstract syntax tree.
8. The apparatus of claim 5, wherein the examples include at least one sub-example to demonstrate a state of the user interface component in a different scenario.
9. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-4.
10. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-4.
CN201911023348.1A 2019-10-25 2019-10-25 Method and device for generating information Active CN110780874B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911023348.1A CN110780874B (en) 2019-10-25 2019-10-25 Method and device for generating information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911023348.1A CN110780874B (en) 2019-10-25 2019-10-25 Method and device for generating information

Publications (2)

Publication Number Publication Date
CN110780874A CN110780874A (en) 2020-02-11
CN110780874B true CN110780874B (en) 2023-07-07

Family

ID=69386644

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911023348.1A Active CN110780874B (en) 2019-10-25 2019-10-25 Method and device for generating information

Country Status (1)

Country Link
CN (1) CN110780874B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112068841B (en) * 2020-09-09 2024-02-23 上海万向区块链股份公司 Method and system for automatically generating project flow document
CN112699279A (en) * 2020-12-31 2021-04-23 百果园技术(新加坡)有限公司 Method, device and equipment for automatically processing components and storage medium
CN113110828A (en) * 2021-04-19 2021-07-13 中国工商银行股份有限公司 Front-end prototype debugging method and device
CN113760356B (en) * 2021-09-10 2024-03-19 北京百度网讯科技有限公司 Differential configuration method, device, equipment and medium of program product

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9244680B2 (en) * 2013-06-28 2016-01-26 International Business Machines Corporation Document quality review and testing
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN109783079A (en) * 2018-12-21 2019-05-21 南京航空航天大学 A kind of code annotation generation method based on program analysis and Recognition with Recurrent Neural Network

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7681118B1 (en) * 2004-07-14 2010-03-16 American Express Travel Related Services Company, Inc. Methods and apparatus for creating markup language documents
CN104820604B (en) * 2015-05-27 2018-08-31 百富计算机技术(深圳)有限公司 A kind of browser applied to POS terminal
CN106569947A (en) * 2016-11-01 2017-04-19 北京大学(天津滨海)新代信息技术研究院 Method and tool for extracting API (Application Program Interface) use example from unit test code
CN108985073B (en) * 2018-07-18 2020-05-22 成都链安科技有限公司 Highly-automated intelligent contract formalized verification system and method
CN109375922A (en) * 2018-09-26 2019-02-22 深圳壹账通智能科技有限公司 A kind of automatic generation method and terminal device of interface document
CN109947433A (en) * 2019-03-28 2019-06-28 优信拍(北京)信息科技有限公司 A kind of generation method of small routine, update method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9244680B2 (en) * 2013-06-28 2016-01-26 International Business Machines Corporation Document quality review and testing
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN109783079A (en) * 2018-12-21 2019-05-21 南京航空航天大学 A kind of code annotation generation method based on program analysis and Recognition with Recurrent Neural Network

Also Published As

Publication number Publication date
CN110780874A (en) 2020-02-11

Similar Documents

Publication Publication Date Title
CN109634598B (en) Page display method, device, equipment and storage medium
CN111274760B (en) Rich text data processing method and device, electronic equipment and computer storage medium
CN109597617B (en) Method and device for quickly generating service page based on template
CN110780874B (en) Method and device for generating information
CN109062563B (en) Method and device for generating page
CN110543297B (en) Method and apparatus for generating source code
CN110020329B (en) Method, device and system for generating webpage
CN110554874A (en) Method and device for reusing webpage components of SaaS platform
CN112684968A (en) Page display method and device, electronic equipment and computer readable medium
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN113031946A (en) Method and device for rendering page component
CN109002282B (en) Method and device for realizing animation effect in web page development
CN111443909A (en) Method and device for generating page
CN113495730A (en) Resource package generation and analysis method and device
CN112954056B (en) Method and device for processing monitoring data, electronic equipment and storage medium
CN113721910A (en) Interface code generation method and device, electronic equipment and computer readable medium
CN110489326B (en) IDS-based HTTPAPI debugging method device, medium and equipment
CN116860286A (en) Page dynamic update method, device, electronic equipment and computer readable medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN113220381A (en) Click data display method and device
CN112181408A (en) Method and device for displaying view list on front page of application program
CN115454956A (en) Log generation method and device, electronic equipment and storage medium
CN110618811A (en) Information presentation method and device
CN115756452A (en) Target page code generation method, device, storage medium and program product

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