CN110780874A - Method and apparatus for generating information - Google Patents

Method and apparatus for generating information Download PDF

Info

Publication number
CN110780874A
CN110780874A CN201911023348.1A CN201911023348A CN110780874A CN 110780874 A CN110780874 A CN 110780874A CN 201911023348 A CN201911023348 A CN 201911023348A CN 110780874 A CN110780874 A CN 110780874A
Authority
CN
China
Prior art keywords
user interface
interface component
source code
target
configuration information
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.)
Granted
Application number
CN201911023348.1A
Other languages
Chinese (zh)
Other versions
CN110780874B (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

Abstract

The embodiment of the disclosure discloses a method and a device for generating information. One embodiment of the method comprises: analyzing a template and a script included in the received user interface component to obtain description information of the user interface component; generating a Markdown document according to the description information; acquiring an example and an example source code of the user interface component; and writing the example label 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. The embodiment realizes automatic generation of the UI component description document and improves the information generation efficiency. At the same time, the generated specification document is made available for rendering of the examples and display of the example source code.

Description

Method and apparatus 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 the front-end technology, the development of the front-end component is greatly improved. With the implementation of a set of UI (User Interface) component libraries, it is generally necessary to provide an explanatory 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 description document of the UI component can provide example rendering related to the UI component and corresponding source code for a developer to read, the development efficiency can be greatly improved. At this stage, manual writing is usually used to generate a description document of the UI component. However, the means of writing is not only costly and inefficient, but also may have a problem of non-uniform styles due to the participation of multiple people in writing.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for generating information.
In a first aspect, an embodiment of the present disclosure provides a method for generating information, where the method includes: analyzing a template and a script included in the received user interface component to obtain description information of the user interface component; generating a Markdown document according to the description information; acquiring an example and an example source code of the user interface component; and writing the example label 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 obtaining the example and example source codes 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 identifiers; and taking the target example and the target example source code as corresponding examples and example source codes of the user interface component.
In some embodiments, the configuration information contained in the configuration file includes an example identifier; and the determining target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identifier of the user interface component includes: determining whether configuration information is included in the configuration file, wherein the configuration information comprises example identification matched with the identification of the user interface component; in response to determining comprising, determining configuration information in the configuration file that the example identifier matches the identifier of the user interface component as target configuration information.
In some embodiments, the parsing the template and the script 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 example includes at least one sub-example for presenting the state of the user interface component in different scenarios.
In a second aspect, an embodiment of the present disclosure provides an apparatus for generating information, the apparatus including: the analysis unit is configured to analyze the template and the script included in the received user interface component to obtain the description information of the user interface component; a generating unit configured to generate a Markdown document based on the explanatory information; an acquisition unit configured to acquire an example of the user interface component and an example source code; and the writing unit is configured to write the example label 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 obtaining unit includes: a first determining unit, configured to determine target configuration information from at least one piece of configuration information included in a pre-established configuration file according to the identifier of the user interface component, wherein the target configuration information includes a target example, and the target example includes an example source code identifier; a source code acquiring unit configured to acquire target example source codes from a preset example source code set according to the example source code identifiers; and the second determining unit is configured to take the target example and the target example source code as the corresponding example and example source code of 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 configuration information is included in the configuration file, wherein the configuration information comprises example identification matched with the identification of the user interface component; in response to determining comprising, determining configuration information in the configuration file that the example identifier matches the identifier 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 example includes at least one sub-example for presenting the state of the user interface component in different scenarios.
In a third aspect, an embodiment of the present disclosure provides an apparatus, including: one or more processors; a storage device, on which one or more programs are stored, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation manner of the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for generating information, the template and the script included in the received user interface component are firstly analyzed to obtain the description information of the user interface component, and then the Markdown document is generated according to the obtained description information. Then, an example of the user interface component and example source code are obtained. Finally, the example tag character string and the example source code established based on the example are written into the Markdown document, thereby obtaining an explanatory document for the user interface component. The automatic generation of the UI component description document is realized, and the information generation efficiency is improved. At the same time, the generated specification document is made available for rendering of the examples and display of the example source code.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for generating information, according to the present disclosure;
FIG. 3 is a composition diagram of the Vue UI component;
fig. 4 is an exemplary diagram of a partial content of a Markdown document generated based on explanatory information of a button component, taking the button component as an example;
FIG. 5 is a schematic diagram of one application scenario of a method for generating information according to the present disclosure;
FIG. 6 is a flow diagram of yet another embodiment of a method for generating information according to the present disclosure;
FIG. 7 is a schematic block diagram illustrating one embodiment of an apparatus for generating information according to the present disclosure;
FIG. 8 is a schematic block diagram of a computer system suitable for use in implementing an electronic device of an embodiment of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. 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 of a method for generating information or an apparatus for generating information to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal apparatuses 101, 102, and 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 portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And 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 backend server may perform processing such as analysis on the received data such as the user interface component, and feed back the processing result (e.g., the explanatory document) to the terminal apparatuses 101, 102, and 103.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the server 105 is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And 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 executed by the terminal devices 101, 102, and 103, or may be executed 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 in accordance with the present disclosure is shown. The method for generating information comprises the following steps:
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 (for example, the terminal apparatus 101, 102, 103 or the server 105 shown in fig. 1) may receive a UI (User Interface) component. By way of example, the UI component herein may refer to a UI component built under the Vue framework, and may also be referred to as a Vue UI component. Vue is a set of progressive JavaScript frames used to build user interfaces. As shown in FIG. 3, in general, the composition of a Vue UI component may contain 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 information may be defined in a template, and attribute (prop), data (data), events (events), methods (methods), and the like information may be defined in a script. In this way, the execution body can parse the template and the script of the UI component, thereby obtaining the description information of the UI component. By way of example, the specification information for the UI component may include, but is not limited to, attribute information, events, methods, comment specifications, slot information, and the like.
In some optional implementations of this embodiment, the step 201 may specifically be performed as follows:
first, the templates and scripts are parsed into abstract syntax trees.
In this implementation, the execution agent may parse the templates and scripts of the user interface components into abstract syntax trees in a variety of ways. As an example, the execution body may parse the template into an Abstract Syntax Tree (AST) using the vue-template-builder module in Vue. Here, an Abstract Syntax Tree (AST), or simply Syntax tree (Syntax tree), is an Abstract representation of the Syntax structure of the source code. It represents the syntactic structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
Then, specification information of the user interface component is acquired based on the abstract syntax tree.
In this implementation, the executive agent may obtain specification information for the user interface component based on the abstract syntax tree obtained from the parsing. In particular, the executing agent may traverse the abstract syntax tree to obtain specification information for the user interface element.
And step 202, generating a Markdown document according to the description information.
In the present embodiment, the execution agent may generate a Markdown document from the UI component specification information obtained in step 201. Specifically, the execution agent may edit the description information obtained in step 201 according to the Markdown document specification, thereby obtaining a Markdown document. Here, Markdown is a markup language that can be written using a plain text editor, and it makes plain text contents have a certain format by a simple markup syntax. As an example, fig. 4 exemplifies a part of the contents of a Markdown document generated based on the specification information of one Button component. It should be noted that information such as tips (attributes), events (events), and the like included in the Markdown document is merely illustrative, and does not limit the content included in the Markdown document.
At step 203, an example of a user interface component and an example source code are obtained.
In the present embodiment, an example (demo) and an example source code of the UI component may be stored in advance inside the execution body. Here, the example may refer to an example capable of rendering presentation. Example source code may refer to example corresponding source code. The execution principal may obtain the examples of the UI component and the example source code in various ways. For example, for the convenience of obtaining, the example and the example source code corresponding to a certain UI component may be stored according to the UI component identifier of the UI component, for example, names of the example and the example source code corresponding to the UI component may be made the same as the UI component identifier. In this way, the execution subject may obtain the example and the example source code corresponding to the UI component according to the UI component identification of the UI component. Here, the 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 the present embodiment, the example may include at least one sub-example, where the at least one sub-example may be used to show states of the user interface component in different scenarios. Taking a Button component as an example, an example titled Button component correspondence may include a plurality of sub-examples titled "basic usage", "disabled state", "text Button", "icon Button", "Button size", "load Button", and the like. Each sub-example comprises code (code) for indicating the name of an example source code corresponding to the sub-example, title for indicating the title of the sub-example, desc for indicating the scene to which the sub-example applies, and the like. To illustrate a number of sub-examples of the Button component, the following is supplemented with corresponding code.
Figure BDA0002247901160000071
It should be noted that the above codes are only exemplary and do not limit the Button component sub-examples.
And step 204, writing the example label character string and the example source code established based on the example into a Markdown document to obtain an explanation document for the user interface component.
In this embodiment, the executing agent may first create an example tag string according to the example obtained in step 203. As an example, the execution body may parse the obtained example according to a preset method, so as to obtain the required example data, perform character string splicing on the example data, and further establish an example tag character string. As an example, the preset method can be set according to actual needs. Thereafter, the execution body may write the above example tag character string and the example source code into the Markdown document obtained in step 202, thereby obtaining an explanatory document for the above user interface component. Here, the document is explained as a document in Markdown format. In practice, because the explanation document is a Markdown formatted document, when a developer views the explanation document, the rendered example and the example source code for the example can be seen. Thus, the development efficiency of developers 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 template and the script included in the UI component in the received UI component library 502 to obtain the description information of the UI component. Thereafter, a Markdown document 503 may be generated based on the UI component specification information. Then, examples and example source code for the UI component are obtained. Finally, the example tag character strings and the example source codes established based on the examples are written into the Markdown document, and a description document for the UI component is obtained.
According to the method provided by the embodiment of the disclosure, the Markdown document is generated based on the description information obtained by analyzing the template and the script of the UI component, and the example tag character string and the example source code corresponding to the example of the UI component are written into the Markdown document, so that the UI component description document is automatically generated, and the information generation efficiency is improved. At the same time, the generated specification document is made available for rendering of the examples and display of the example source code.
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:
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 is not described herein again.
And 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 is not described herein 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 identifier of the user interface component.
In this embodiment, a configuration file may be pre-established inside the execution main 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 an example, where the example may contain a variety of information, such as a name, a description, an example source code identification, and so on. Here, the example source code identification may be used to uniquely identify the example corresponding source code. In practice, the source codes of all examples may be stored in a certain position, so that the execution subject may obtain the example source code corresponding to the example from the position according to the example source code identifier included in a certain example.
In this way, the execution subject may determine target configuration information from at least one piece of configuration information contained in the configuration file according to the identity 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 identity.
In some optional implementations of this embodiment, the configuration information included in the configuration file may include an example identifier. And the above step 603 may be specifically performed as follows:
first, it is determined whether configuration information is included in the configuration file that the example identification matches the identification of the user interface component.
In this implementation, the execution subject may determine whether configuration information whose example identifier matches (e.g., is the same as) the identifier of the user interface component is included in the configuration file.
Then, responsive to determining, comprising, determining the configuration information in the configuration file that the example identification matches the identification of the user interface component as the target configuration information.
In this implementation, if it is determined that configuration information whose example identifier matches the identifier of the user interface component is included in the configuration file, the execution subject may determine, as the target configuration information, configuration information whose example identifier matches the identifier of the user interface component in the configuration file.
And step 604, acquiring target example source codes from a preset example source code set according to the example source code identifiers.
In this embodiment, the execution subject 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, example source code for respective examples of the user interface component may be included in the example set of source code.
Step 605, the target instance and the target instance source code are used as the corresponding instance and instance source code of the user interface component.
In this embodiment, the execution subject may use the target example included in the target configuration information determined in step 603 and the target example source code acquired in step 604 as the example and the example source code corresponding to the user interface component.
Step 606, writing the example tag character string and the example source code established based on the example into the Markdown document to obtain an explanatory document for the user interface component.
In this embodiment, step 606 is similar to step 204 of the embodiment shown in fig. 2, and is not described herein again.
As can be seen from fig. 6, compared to the embodiment corresponding to fig. 2, the flow 600 of the method for generating information in the present embodiment highlights the steps of obtaining an example of a user interface component and an example source code based on a configuration file. Therefore, the scheme described in the embodiment can realize flexible configuration of the example of the user interface component and the example source code by modifying the configuration file, so that the generated description document of the user interface component is more in line with the requirement.
With further reference to fig. 7, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for generating information, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 7, the apparatus 700 for generating information of the present embodiment includes: analysis section 701, generation section 702, acquisition section 703, and writing section 704. The parsing unit 701 is configured to parse a template and a script included in a received user interface component to obtain description information of the user interface component; the generating unit 702 is configured to generate a Markdown document based on the above-mentioned explanatory information; the obtaining unit 703 is configured to obtain examples of the user interface component and example source codes; the writing unit 704 is configured to write the example tag character string created based on the above example and the above example source code into the Markdown document, resulting in a description document for the user interface component.
In this embodiment, specific processes of the analyzing unit 701, the generating unit 702, the obtaining unit 703 and the writing unit 704 of the apparatus 700 for generating information and technical effects brought thereby may refer to related descriptions of step 201, step 202, step 203 and step 204 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementation manners of this embodiment, the obtaining unit 703 includes: a first determining unit (not shown in the figures) configured to determine target configuration information from at least one piece of configuration information included in a pre-established configuration file according to the identifier of the user interface component, wherein the target configuration information includes a target example, and the target example includes an example source code identifier; 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 example source code identifiers; 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 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 configuration information is included in the configuration file, wherein the configuration information comprises example identification matched with the identification of the user interface component; in response to determining comprising, determining configuration information in the configuration file that the example identifier matches the identifier 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 the embodiment, the example includes at least one sub-example, and the at least one sub-example is used for showing states of the user interface component in different scenes.
Referring now to fig. 8, a schematic diagram of an electronic device (e.g., a 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 only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 8, an electronic device 800 may include a processing means (e.g., central processing unit, graphics processor, etc.) 801 that may perform various appropriate actions and processes in accordance with 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 necessary for the operation of the electronic apparatus 800 are also stored. The processing apparatus 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 bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 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 illustrates an electronic device 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 8 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the 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 illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program, when executed by the processing apparatus 801, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium described in 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. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 embodiments of the 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. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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 a template and a script included in the received user interface component to obtain description information of the user interface component; generating a Markdown document according to the description information; acquiring an example and an example source code of the user interface component; and writing the example label 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.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a parsing unit, a generating unit, an obtaining unit, and a writing unit. Where the names of these elements do not in some cases constitute a limitation on the elements themselves, for example, the retrieving element may also be described as an "element that retrieves examples of user interface components and example source code as described above".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology 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-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (12)

1. A method for generating information, comprising:
analyzing a template and a script included in a received user interface component to obtain description information of the user interface component;
generating a Markdown document according to the description information;
obtaining an example and example source code for the user interface component;
and writing the example label 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.
2. The method of claim 1, wherein the obtaining the example of the user interface component and the example source code comprises:
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 identifiers;
and taking the target example and the target example source code as corresponding example and example source codes of the user interface component.
3. The method of claim 2, wherein the configuration information contained in the configuration file includes an instance identification; and
determining target configuration information from at least one piece of configuration information contained in a pre-established configuration file according to the identifier of the user interface component, including:
determining whether configuration information is included in the configuration file whose example identification matches the identification of the user interface component;
determining, in response to determining, that the configuration information in the configuration file that the example identifier matches the identifier of the user interface component is the target configuration information.
4. The method of claim 1, wherein the parsing the template and the script included in the received user interface component to obtain the description information of the user interface component comprises:
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.
5. The method of claim 1, wherein the examples include at least one sub-example for presenting a state of the user interface component in a different scenario.
6. An apparatus for generating information, comprising:
the analysis unit is configured to analyze the template and the script 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 obtaining unit configured to obtain 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 explanatory document for the user interface component.
7. The apparatus of claim 6, wherein the obtaining unit comprises:
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 identifier of the user interface component, wherein the target configuration information includes a target example, and the target example includes an example source code identifier;
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 identifiers;
a second determination unit configured to take the target example and the target example source code as corresponding example and example source codes of the user interface component.
8. The apparatus of claim 7, wherein the configuration information contained in the configuration file includes an instance identification; and
the first determination unit is further configured to:
determining whether configuration information is included in the configuration file whose example identification matches the identification of the user interface component;
determining, in response to determining, that the configuration information in the configuration file that the example identifier matches the identifier of the user interface component is the target configuration information.
9. The apparatus of claim 6, 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.
10. The apparatus of claim 6, wherein the examples comprise at least one sub-example to show a state of the user interface component in different scenarios.
11. An apparatus, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-5.
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 true CN110780874A (en) 2020-02-11
CN110780874B 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)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112068841A (en) * 2020-09-09 2020-12-11 上海万向区块链股份公司 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
CN113760356A (en) * 2021-09-10 2021-12-07 北京百度网讯科技有限公司 Differential configuration method, device, equipment and medium of program product

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8255794B2 (en) * 2004-07-14 2012-08-28 American Express Travel Related Services Company, Inc. Methods and apparatus for creating markup language documents
CN104820604A (en) * 2015-05-27 2015-08-05 百富计算机技术(深圳)有限公司 Browser applied to POS terminal
US9244680B2 (en) * 2013-06-28 2016-01-26 International Business Machines Corporation Document quality review and testing
CN106569947A (en) * 2016-11-01 2017-04-19 北京大学(天津滨海)新代信息技术研究院 Method and tool for extracting API (Application Program Interface) use example from unit test code
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN108985073A (en) * 2018-07-18 2018-12-11 成都链安科技有限公司 A kind of supermatic intelligent forms of contract chemical examination card system and method
CN109375922A (en) * 2018-09-26 2019-02-22 深圳壹账通智能科技有限公司 A kind of automatic generation method and terminal device of interface document
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
CN109947433A (en) * 2019-03-28 2019-06-28 优信拍(北京)信息科技有限公司 A kind of generation method of small routine, update method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8255794B2 (en) * 2004-07-14 2012-08-28 American Express Travel Related Services Company, Inc. Methods and apparatus for creating markup language documents
US9244680B2 (en) * 2013-06-28 2016-01-26 International Business Machines Corporation Document quality review and testing
CN104820604A (en) * 2015-05-27 2015-08-05 百富计算机技术(深圳)有限公司 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
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN108985073A (en) * 2018-07-18 2018-12-11 成都链安科技有限公司 A kind of supermatic intelligent forms of contract chemical examination card system and method
CN109375922A (en) * 2018-09-26 2019-02-22 深圳壹账通智能科技有限公司 A kind of automatic generation method and terminal device of interface document
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
CN109947433A (en) * 2019-03-28 2019-06-28 优信拍(北京)信息科技有限公司 A kind of generation method of small routine, update method and device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
MATERING JS: ""An Introduction to Vue Template Compiler"", 《HTTPS://MASTERINGJS.IO/TUTORIALS/VUE/TEMPLATE-COMPILER》 *
MATERING JS: ""An Introduction to Vue Template Compiler"", 《HTTPS://MASTERINGJS.IO/TUTORIALS/VUE/TEMPLATE-COMPILER》, 31 May 2019 (2019-05-31), pages 1 - 3 *
梅楼封: ""vuepress:Vue官方出品的文档生成器"", 《HTTPS://JUEJIN.CN/POST/6844903591262552077》 *
梅楼封: ""vuepress:Vue官方出品的文档生成器"", 《HTTPS://JUEJIN.CN/POST/6844903591262552077》, 15 April 2018 (2018-04-15), pages 1 - 8 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112068841A (en) * 2020-09-09 2020-12-11 上海万向区块链股份公司 Method and system for automatically generating project flow document
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
CN113760356A (en) * 2021-09-10 2021-12-07 北京百度网讯科技有限公司 Differential configuration method, device, equipment and medium of program product
CN113760356B (en) * 2021-09-10 2024-03-19 北京百度网讯科技有限公司 Differential configuration method, device, equipment and medium of program product

Also Published As

Publication number Publication date
CN110780874B (en) 2023-07-07

Similar Documents

Publication Publication Date Title
CN109634598B (en) Page display method, device, equipment and storage medium
CN110780874B (en) Method and device for generating information
CN111274760B (en) Rich text data processing method and device, electronic equipment and computer storage medium
US10565293B2 (en) Synchronizing DOM element references
CN110543297B (en) Method and apparatus for generating source code
CN109062563B (en) Method and device for generating page
CN110554874A (en) Method and device for reusing webpage components of SaaS platform
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN112684968A (en) Page display method and device, electronic equipment and computer readable medium
CN109582317B (en) Method and apparatus for debugging hosted applications
CN109002282B (en) Method and device for realizing animation effect in web page development
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
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
CN111813685A (en) Automatic testing method and device
CN113495730A (en) Resource package generation and analysis method and device
CN116860286A (en) Page dynamic update method, device, electronic equipment and computer readable medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN112947912A (en) Method and device for generating code, electronic equipment and storage medium
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
CN113656041A (en) Data processing method, device, equipment and storage medium
CN114443905A (en) Interface document updating method and device, electronic equipment and readable storage medium
CN111414331A (en) Document importing method and device of online collaborative knowledge base, storage medium and equipment

Legal Events

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