#!/usr/bin/env python # coding: utf-8 # # [Doc4TF](https://github.com/tonyjurg/Doc4TF) # #### *Automatic creation of feature documentation for existing Text-Fabric datasets* # # Version and release date: # In[1]: scriptVersion="0.5" scriptDate="May 13, 2024" # Additional notes on instal requirements added May 26, 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 - Changelog # * 7 - 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 dictionary 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`. Text-Fabric requires at least Python version 3.7.0. If not installed yet, it can be installed using `pip`. More details on installing the Text-Fabric package can be found in [tf.about.install](https://annotation.github.io/text-fabric/tf/about/install.html). # # 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. # # Which dataset will be loaded is specified in the parameters as detailed below: # ``` # A = use ("{GitHub user name}/{repository name}", version="{version}", hoist=globals()) # ``` # For various options regarding other possible storage locations, and other load options, see the documentation for function [`use`](https://annotation.github.io/text-fabric/tf/app.html#tf.app.use). # In[3]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[5]: # 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[7]: # load the app and data A = use ("saulocantanhede/tfgreek2", version="0.5.7", hoist=globals()) # # 4 - Creation of the dataset # ## 4.1 - Setting up some global variables # ##### [Back to TOC](#TOC) # In[9]: # 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.7](https://github.com/saulocantanhede/tfgreek2)" customPageTitleHTML="N1904 Greek New Testament saulocantanhede/tfgreek2 - 0.5.7" # 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='md' # 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 # 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/blob/main/CreateFeatureDoc.ipynb)' footerHTML=f'\n
Created on {formatted_date} using Doc4TF - version {scriptVersion} ({scriptDate})