Script Structure json - toolbuddy/docoGen GitHub Wiki



Overview

  • docoGen structure is formed by JSON, and has its special file extension called .docogen
  • Lately before version 0.1.0, we support markdown format to generate LaTeX, too!
  • Simply can separate to 2 parts: Main Structure and Optional Structure
  • And we will discuss each part in the following chapter.
  • Complete demonstration goes here.
// The entire docoGen look like this:
{
    title: ... ,
    options: ...,
    author: [ ... ],
    article: [ ... ],
    reference: [ ... ]
}

Main structure of .docogen

  • If you have multiple docogen files, only one file need to include this structure.
  • Elements of Main structure
    • title: the big title of generated paper.
    • options: some optional configuration of generating work.
      • type: the type of LaTeX paper.
    {
    ...
        /* only used in LaTeX */
        options: {
            type: "article"
            , ...
        }
    }
    
    • author: the author/collaborator of this paper.
    {
    ...
        author: [
            {
                name: "author 1",
                email: "...",
                phone: "...",
                website: "..."
            }, ...
        ]
    }
    
    • abstract: some words/sentences of this paper.
    {
    ...
        /* using string array */
        abstract: [
            "sentence 1"
            ,"sentence 2"
            , ...
        ]
    }
    
    • article[optional]
    • reference[optional]

Optional structure

  • Those elements can be placed at any docogen file under your project.
  • When using module docogen to generate document page/pdf, the docogen system will collect and merge all the docogen files, and using priority in your article to sort those merged article.
  • Elements of Optional structure
    • article: different kinds of content.
    • reference: using \\cite{...(reference_name)} in the content and then can use reference! And you can put your reference in any docogen file.

Detail of article

  • In this section, we will show you the functionality of each field in docogen.
  • And it will continuously being modified, updated.

title

  • Title of this article.

priority

  • Because we support user using multiple docogen files at once, so we create priority to represent the order of article.
  • The priority order can range from negative number to positive number, any number you pick, the docoGen will sort them by priority. (from negative to positive)

content

  • Each article element will store the main data/info object in content field.
  • Have name field to specify the title of this content.
  • And put the data object into data field, using type field to decide which storage format of data field would be.
  • Next, we will discuss type of data in each content.

none

  • none: only enlarge the name field, and then append the data[...].info(text) ( in data(array) ) under this title.
// content with "none"
{
    name: "content title",
    type: "none",
    data: [
        { info: "your word here" }
    ]
}

text

  • text: Treat as unordered list in LaTeX, and each data[...].info equal to an item in this part of content.
// content with "text" (almost same as "none" type)
{
    name: "content title",
    type: "text",
    data: [
        { info: "your word here" }
    ]
}

list

  • list: here comes the format of list
    • Each name represent as one item of list, and in the same array will in same layer of list structure.
    • If one list item have the subitems of it, just using the same structure in subitems. Otherwise, don't need to add subitems field.
    • e.g.
    {
        name: "List 1",
        subitems: []
    },{
        name: "List 2"
    }
    

table

  • using our table style.
  • the necessary attributes:
    • column name
    • colum size(by the length of data)
    • tablen title
    • each column value(array)
{
    name: "content title",
    type: "table",
    data: [
        { 
             title: "Col 1 title",
             value: [ "Col-1-value1", "Col-1-value2", "Col-1-value3" ]
        },
        { ... }
    ]
}

formula

  • support info, inline, display and equation 4 categories.
    • info: normal words
    • inline: inline mode of mathematic representation.
    • display: display mode of mathematic representation.
    • equation: enclose by {equation} tag.
  • you can also merge those field together (any combination with 4 type) within one block, and it will be in the order of info -> inline -> display -> equation.
{
    name: "content title",
    type: "formula",
    data: [
        { info: "normal sentence(doesn't contain any mathmetic equation)" },
        { inline: "math equation(with "( )"), e.g. \(x^2 + y^2 = z^2\) },
        { display: "math equation(with "[ ]"), e.g. \[ x^n + y^n = z^n \])" },
        { equation: "math equation(which will be enclose by \begin{equation} tag)" },
        // Merged format -> 
        {
           info: ...,
           display: ...
        }
    ]
}

code

  • support 2 type of format, if you want to include a large example, you can use src field; And if you just want to show a small instance, you can use raw field. (See the example down below)
  • after 0.1.3, relative code file path is available!
  • Reminder: default value of flag is rel (relative)!
{
    name: "content title",
    type: "code",
    data: [
        { 
             // Type 1
             lang: "your language (e.g. C, C++, matlab, ... etc)",
             caption: "your caption about the following instance",
             src: "the absolute path to your code"
        },
        { 
             // Type 2
             lang: "your language (e.g. C, C++, matlab, ... etc)",
             caption: "your caption about the following instance",
             raw: "put your code content directly"
        },
        { 
             // Type 3 (relative usage)
             lang: "your language (e.g. C, C++, matlab, ... etc)",
             flag: "rel"
             caption: "your caption about the following instance",
             src: "the relative path to your code"
        },
        { ... }
    ]
}

figure

  • This figure(array) field let you put your image/figure to support your thesis/argument.
  • Absolutive/Relative Support. (On windows, pdfLaTeX need absolutive path; So in docoGen engine, we will do that for you)
  • flag: rel/abs
  • Need to set the flag (default value is rel, if this field left blank)
    • If flag is abs, we will directly use the path (without path resolving)
    • If flag is rel, we will base on the script location and do the path resolving.
  • The format have:
{
    name: "title image/figure",
    type: "figure",
    data: [
        {
            path: "absolute path of your image",
            flag: "abs/rel",
            align: "alignment method of your image",
            size: "size of your image",
            caption: "caption of image/figure"
        }, { ... }
    ]
}

web-restful-api

  • Web extension support
{
    name: "Restful api support",
    type: "web-restful-api",
    data: [
        {
            method: "GET/POST",
            usage: "usage of this url/function",
            url: "api url goes here(e.g. http://...)",
            description: "detail of this url/function",
            field: [ { name: "parameter field name", type: "parameter data type"}, ... ],
            error: [ "error msg 1", "error msg 2", ... ],
            success: [ "success msg 1", "success msg 2", ... ],
        }, { ... }
    ]
}

figure (outside)

  • Same functionality as the figure inside content.
{
    ...
    figure: [
        {
            path: "absolute path of your image",
            flag: "abs/rel",
            align: "alignment method of your image",
            size: "size of your image",
            caption: "caption of image/figure"
        }, { ... }
    ]
}

subarticle

  • If your article still want to discuss more deeper, then just add the same structure introduced above in this field, and the docogen will put it into subsection and go on.
  • subarticle of subarticle is available too!