'During the build process directives are parsed as nodes, and then
later the nodes are built into the target format (html, latex, pdf, etc.)
run is called automatically during the parsing process and is expected to
return a list of nodes. Here we set up our parsing environment, then defer
to a runhandler callback for parsing. The callback is determined by the
navigation-steps option of the screenshot directive (in _parse_nav_steps).
Language xx can be set in conf.py or by:
make SPHINXOPTS="-D language=xx" html
Build language can be accessed from the BuildEnvironment.'

def run(self):

    self.env = self.state.document.settings.env
    return_nodes = []
    if (not hasattr(self.env, 'screenshot_all_screenshots')):
        self.env.screenshot_all_screenshots = []
    if (not ('registered' in self.options)):
        self.options['registered'] = False
    else:
        self.options['registered'] = (True if (self.options['registered'] == 'true') else False)
    if ('focus' in self.options):
        self.focus_selector = self.options['focus']['id']
        self.focus_annotation = self.options['focus']['annotation']
    if ('user-role' in self.options):
        self.user_role = self.options['user-role']
    else:
        self.user_role = 'guest'
    if ('url' in self.options):
        self.url = self.options['url']
    if ('navigation-steps' in self.options):
        from hashlib import md5
        self.filename = md5(''.join(map(str, self.options.values()))).hexdigest()
        runhandler = self.options['navigation-steps']['runhandler']
        args = self.options['navigation-steps']['args']
        return_nodes.append(getattr(self, runhandler)(**args))
    else:
        raise NotImplementedError('navigation-steps    is    a    required    option    for    screenshot    directives!')
    return return_nodes
