#!/usr/bin/env python # coding: utf-8 # # [Doc4TF](https://github.com/tonyjurg/Doc4TF) # #### *Automatic creation of feature documentation for existing Text-Fabric datasets* # # Version: 0.3 (Jan. 24, 2024); fixing bug [10](https://github.com/tonyjurg/Doc4TF/issues/10) (Feb. 2, 2024) # ## Table of content # * 1 - Introduction # * 2 - Setting up the environment # * 3 - Load Text-Fabric data # * 4 - Creation of the dataset # * 4.1 - Setting up some global variables # * 4.2 - Store all relevant data into a dictionary # * 5 - Create the documentation pages # * 5.1 - Create the set of feature pages # * 5.2 - Create the index pages # * 6 - Licence # # 1 - Introduction # ##### [Back to TOC](#TOC) # # Ideally, a comprehensive documentation set should be created as part of developing a Text-Fabric dataset. However, in practice, this is not always completed during the initial phase or after changes to features. This Jupyter Notebook contains Python code to automatically generate (and thus ensure consistency) a documentation set for any [Text-Fabric](https://github.com/annotation/text-fabric) dataset. It serves as a robust starting point for the development of a brand new documentation set or as validation for an existing one. One major advantage is that the resulting documentation set is fully hyperlinked, a task that can be laborious if done manually. # # The main steps in producing the documentation set are: # * Load a Text-Fabric database # * Execute the code pressent in the subsequent cells. The code will: # * Construct the python dictionarie stroring relevant data from the TF datase # * Create separate files for each feature # * Create a set of overview pages sorting the nodes accordingly # # The output format can be either Markdown, the standard for feature documentation stored on GitHub using its on-site processor, or HTML, which facilitates local storage and browsing with any web browser. # # 2. Setting up the environment # ##### [Back to TOC](#TOC) # Your environment should (for obvious reasons) include the Python package `Text-Fabric`. If not installed yet, it can be installed using `pip`. Further it is required to be able to invoke the Text-Fabric data set (either from an online resource, or from a localy stored copy). There are no further requirements as the scripts basicly operate 'stand alone'. # # 3 - Load Text-Fabric data # ##### [Back to TOC](#TOC) # At this step, the Text-Fabric dataset is loaded, which embedded data will be used to create a documentation set. For various options regarding other possible storage locations, see the documentation for function [`use`](https://annotation.github.io/text-fabric/tf/app.html#tf.app.use). # In[1]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[2]: # Loading the Text-Fabric code # Note: it is assumed Text-Fabric is installed in your environment from tf.fabric import Fabric from tf.app import use # In[3]: # load the app and data A = use ("saulocantanhede/tfgreek2", version="0.5.5", hoist=globals()) # # 4 - Creation of the dataset # ## 4.1 - Setting up some global variables # ##### [Back to TOC](#TOC) # In[4]: # If the following variable is set, it will be used as title for all pages. It is intended to the describe the dataset in one line # customPageTitleMD="N1904 Greek New Testament [saulocantanhede/tfgreek2 - 0.5.4](https://github.com/saulocantanhede/tfgreek2)" # customPageTitleHTML="N1904 Greek New Testament saulocantanhede/tfgreek2 - 0.5.4" # Specify the location to store the resulting files, relative to the location of this notebook (without a trailing slash). resultLocation = "results" # Type of output format ('html' for HTML, 'md' for Mark Down, or 'both' for both HTML and Mark Down) typeOutput='both' # HTML table style definition (only relevant for HTML output format) htmlStyle='' # Limit the number of entries in the frequency tables per node type on each feature description page to this number tableLimit=10 # This switch can be set to 'True' if you want additional information, such as dictionary entries and file details, to be printed. For basic output, set this switch to 'False'. verbose=False # The version number of the script scriptVersion="0.3" scriptDate="Jan. 24, 2024" # Create the footers for MD and HTML, include today's date from datetime import datetime today = datetime.today() formatted_date = today.strftime("%b. %d, %Y") footerMD=f'\n\nCreated on {formatted_date} using [Doc4TF version {scriptVersion} ({scriptDate})](https://github.com/tonyjurg/Doc4TF)' footerHTML=f'\n
Created on {formatted_date} using Doc4TF - version {scriptVersion} ({scriptDate})