JupyDoc technical detalis

2020-11-17 16:11

This document contains various technical details.

back

1. Client Example

If this document was invoked to serve as a client, as the Manual document does, its attribute client_mode would be set: Now it is in fact False.

To set this, the DocMan function call needs to have a parameter as_client set to True.

top

2. Object Replacement

A key feature of jupydoc is its ability to recognize the class of a variable appearing in the document, and replace it with an instance of a "wrapper" class, which implements a alternative to the __str__ method of the original class. This is done by default for Figure, DataFrame and dict. It happens in the class jupydoc.replacer.ObjectReplacer, which inherits from dict. An instance is in the Publisher instance.

So in the constructor of a subclass, one can modify this instance, using 'update`, to change current keyword args, or add a new wrapper class. A wrapper class is instantiated with two arguments: the instance that it will interpret, and the kwargs.

Note If the object to be displayed is an attribute of a class, {self.something}, then the replacer only "sees" self, and will not process the something. The current solution is to create a variable local to the method.

top


Document Technicals, From module jupydoc.documents.py, created using jupydoc on 2020-11-17 16:11
Saved to /mnt/c/Users/thbur/OneDrive/work/tburnett.github.io/Technicals

Python source code
class Technicals(DocPublisher):
    """
    title: JupyDoc technical detalis
    sections: client_example object_replacement

    abstract: This document contains various technical details.
    """
    def client_example(self):
        """Client Example

        If this document was invoked to serve as a client, as the Manual document does,
        its attribute `client_mode` would be set: Now it is in fact **{self.client_mode}**.

        To set this, the `DocMan` function call needs to have a parameter `as_client` set 
        to True. 

        """
        self.publishme()

    def object_replacement(self):
        """Object Replacement

        A key feature of jupydoc is its ability to recognize the class of a 
        variable appearing in the document, and  replace it with an instance of a "wrapper" class, 
        which implements a alternative to the `__str__` method of the 
        original class. This is done by default for Figure, DataFrame and dict.
        It happens in the class `jupydoc.replacer.ObjectReplacer`, which inherits from `dict`. 
        An instance is in the Publisher instance.


        So in the constructor of a subclass, one can modify this instance, using 'update`, to change current keyword args, or 
        add a new wrapper class.
        A wrapper class is instantiated with two arguments: the instance that it will interpret, and the kwargs. 

        **Note**
        If the object to be displayed is an attribute of a class, `{{self.something}}`, then the replacer only 
        "sees" `self`, and will not process the `something`. The current solution is to create a variable local to
        the method. 
        """
        #---------------------------------------------------------------------------------
        self.publishme()