===================== Generate HTML reports ===================== Writing design documentation is often something that needs to be done after the design work has been finished. By then, all kinds of information needs to be collected and structured in a document, while in many cases new projects are already taking most of the time. This undesirable but almost always inevitable practice can be prevented if the design work goes hand in hand with generation of the design documents. SLiCAP supports this with the generation of web-based design documentation in which figures, tables, expressions and ASCII files can be updated while running SLiCAP-MATLAB scripts. In this way, presentations and documentation can be kept up-to-date with the actual state of the design. SLiCAP distinguishes two types of html pages: - index pages: used for displaying tables of contents with links to other pages The attribute *ini.htmlIndex* is the name of the active index page - data pages: used for displaying all kinds of design data, such as, tables, equations, text, graphs, images, etc. The attribute *ini.htmlPage* is the name of the active data page. - A list with the names of all the html pages is stored in *ini.htmlPages* Detailed information about all html functions can be found in the module reference `SLiCAPhtml.py <../reference/SLiCAPhtml.html>`_. .. _html: ------------------- HTML site structure ------------------- The structure of the project web site that can be generated with SLiCAP will be discussed below. Main Index.html --------------- Initialization of a project generates an *index.html* file in the *html/* project subdirectory. This file will hold the main table of contents of your project. Each time you check a circuit netlist that resides in the project directory, a list entry will be generated in this index file. .. code-block:: python >>> from SLiCAP import * >>> prj = initProject('My first RC network') # Initialize a SLiCAP project >>> # and create main index page >>> print(ini.htmlIndex) # print the active index page index.html Circuit index file ------------------ With the checking of a circuit, a circuit index page is generated: .. code-block:: python >>> from SLiCAP import * >>> prj = initProject('My first RC network') # Initialize a SLiCAP project >>> # and create main index page >>> instr = instruction() # Create an instance of an instruction object >>> instr.setCircuit('myFirstRCnetwork.cir') # Create a circuit from 'myFirstRCnetwork.cir' >>> # and create circuit index page No errors found for circuit: 'My first RC network' from file: 'myFirstRCnetwork.cir'. >>> print(ini.htmlIndex) # print the active index page My-first-RC-network_index.html --------------------- Start a new html page --------------------- It is a good practice to start a new html (data) page after checking the circuit, this prevents output to be writen to index files which would mess up the table of contents. A new html data page can be created by evoking the command *htmlPage(< pageTitle >)*, in which *pageTitle* is the title of the new page (without .html file extension). After creation this new page is automatically assigned as active html data page. With the creation of a data page, a link to this data page is placed on the active index page. .. code-block:: python >>> from SLiCAP import * >>> prj = initProject('My first RC network') # Initialize a SLiCAP project >>> # and create main index page >>> instr = instruction() # Create an instance of an instruction object >>> instr.setCircuit('myFirstRCnetwork.cir') # Create a circuit from 'myFirstRCnetwork.cir' >>> # and create circuit index page No errors found for circuit: 'My first RC network' from file: 'myFirstRCnetwork.cir'. >>> htmlPage('Circuit data') # Create a new html data page and make it the >>> # active data page and returns the HTML code: >>> #
This is some text including $\LaTeX$ code.
' --------------------------------- Place a text file on an HTML page --------------------------------- You can place the contents of a text file, including html code and :math:`\LaTeX` code on the active HTML file with the instruction: .. code-block:: python >>> file2html("myIntroduction.txt") By default, the text file should be located in the */txt* sub directory in your project folder. You can change the path to this file in the file *'SLiCAPconfig.py'* in the project folder. This function returns the contents of the file in string format. ------------------------------ Place an image on an HTML page ------------------------------ You can place an image on the active HTML page and assign a caption and a label to it. .. code-block:: python >>> img2html("myCircuit.svg", 800, caption="Schematic diagram of my circuit", "label="myCircuitLabel") 'html/img/myCircuit.svg' This places: *''* on the active html page. It also copies the image file to the */img* subdirectory of the */html* directory in the project folder. By default, the image file should be located in the */img* sub directory in your project folder. You can change the path to this file in the file *'SLiCAPconfig.py'* in the project folder. This function returns the path to the image file in string format. ---------------------------------------------- Place the netlist of a circuit on an HTML page ---------------------------------------------- You can place the netlist of the circuit as pre formatted text (fixed width font) on the active HTML page and add a label to it. .. code-block:: python >>> netlist2html("myFirstRCnetwork.cir", label="netlistLabel") '"My First RC network" V1 N001 0 V value=1 dc=0 dcvar=0 noise=0 R1 N001 out {R} C1 out 0 {C} .param R=1k C={1/(2*pi*R*f_c)} f_c=1k .end' By default, the netlist file (*.cir* file extension) file should be located in the */cir* sub directory in your project folder. You can change the path to this file in the file *'SLiCAPconfig.py'* in the project folder. This function returns the code placed on the active HTML page. ------------------------------------------------ Place the flattened circuit data on an HTML page ------------------------------------------------ SLiCAP uses an expanded circuit for analysis. In this circuit, elements of built-in sub circuit models, such as, operational amplifiers and semiconductor devices, as well as elements of user-defined sub circuits are added and connected to the main circuit. All elements of the expanded (flattened) circuit with their nodes, references and parameters can be displayed on the active HTML page using one command: .. code-block:: python >>> instr = instruction() >>> instr.setCircuit("myFirstRCnetwork.cir") >>> htmlPage("Circuit data") >>> elementData2html(instr.circuit, label="circuitElements", caption="Expanded circuit") This function returns the code placed on the active HTML page. ------------------------------------ Place all parameters on an HTML page ------------------------------------ You can list all parameters used in expressions of circuit elements and in parameter definitions on the active HTML page. The instruction *params2html(