예제 #1
0
    def execute(self, context):
        n = context.active_node

        string_dir = remapper.get(n.bl_idname)
        filename = n.__module__.split('.')[-1]
        help_url = string_dir + '/' + filename

        # first let's find if this is a valid doc file, by inspecting locally for the rst file.
        VALID = False
        try:
            tk = os.path.join(os.path.dirname(sverchok.__file__), 'docs', 'nodes', string_dir.replace(' ', '_'), filename + '.rst')
            print(tk)
            VALID = exists(tk) and isfile(tk)
        except:
            pass

        if not VALID:
            self.throw_404(n)
            return {'CANCELLED'}

        # valid doc link!
        help_url = help_url.replace(' ', '_')
        if self.kind == 'online':
            destination = 'http://nikitron.cc.ua/sverch/html/nodes/' + help_url + '.html'
        else:
            basepath = os.path.dirname(sverchok.__file__) + '/docs/nodes/'
            destination = r'file:///' + basepath + help_url + '.rst'

        webbrowser.open(destination)
        return {'FINISHED'}
예제 #2
0
    def execute(self, context):
        n = context.active_node

        string_dir = remapper.get(n.bl_idname)
        filename = n.__module__.split('.')[-1]
        help_url = string_dir + '/' + filename

        # first let's find if this is a valid doc file, by inspecting locally for the rst file.
        VALID = False
        try:
            tk = os.path.join(os.path.dirname(sverchok.__file__), 'docs', 'nodes', string_dir.replace(' ', '_'), filename + '.rst')
            VALID = exists(tk) and isfile(tk)
        except:
            pass

        if not VALID:
            self.throw_404(n)
            return {'CANCELLED'}

        # valid doc link!
        help_url = help_url.replace(' ', '_')
        if self.kind == 'online':
            destination = 'http://nikitron.cc.ua/sverch/html/nodes/' + help_url + '.html'
        else:
            basepath = os.path.dirname(sverchok.__file__) + '/docs/nodes/'
            destination = r'file:///' + basepath + help_url + '.rst'

        webbrowser.open(destination)
        return {'FINISHED'}
예제 #3
0
    def execute(self, context):
        n = context.active_node

        string_dir = remapper.get(n.bl_idname)
        if not string_dir: #external node
            print('external_node')
            return external_node_docs(self, n, self.kind)

        filename = n.__module__.split('.')[-1]
        if filename in ('mask','mask_convert','mask_join'):
            string_dir = 'list_masks'
        elif filename in ('modifier'):
            string_dir = 'list_mutators'
        elif string_dir == 'analyzers':
            string_dir = 'analyzer'
        elif string_dir == 'cad':
            string_dir = 'CAD'

        help_url = string_dir + '/' + filename
        # first let's find if this is a valid doc file, by inspecting locally for the rst file.
        VALID = False
        try:
            tk = get_docs_filepath(string_dir, filename)
            print(tk)
            VALID = exists(tk) and isfile(tk)
            # if is not valid we check if it is another folder (for nodes in Alpha, Beta, CAD...)
            if not VALID:
                for folder in nodes_dict.keys():
                    tk = get_docs_filepath(folder, filename)
                    VALID = exists(tk) and isfile(tk)
                    if VALID:
                        help_url = folder + '/' + filename
                        break
        except:
            pass

        if not VALID:
            self.throw_404(n)
            return {'CANCELLED'}

        # valid doc link!
        help_url = help_url.replace(' ', '_')
        if self.kind == 'online':
            destination = 'http://nortikin.github.io/sverchok/docs/nodes/' + help_url + '.html'
        elif self.kind == 'offline':
            basepath = os.path.dirname(sverchok.__file__) + '/docs/nodes/'
            destination = r'file:///' + basepath + help_url + '.rst'
        elif self.kind == 'github':
            destination = 'https://github.com/nortikin/sverchok/blob/master/docs/nodes/' + help_url + '.rst'

        webbrowser.open(destination)
        return {'FINISHED'}
예제 #4
0
    def execute(self, context):
        n = context.active_node
        fpath = self.get_filepath_from_node(n)
        string_dir = remapper.get(n.bl_idname)

        with sv_preferences() as prefs:

            if prefs.real_sverchok_path:
                _dst = os.path.dirname(sverchok.__file__)
                _src = prefs.real_sverchok_path
                fpath = fpath.replace(_dst, _src)

            if self.kind == 'internal':
                self.view_source_internal(context.screen.areas, fpath)

            elif self.kind == 'external':
                self.view_source_external(prefs, fpath)

            return {'FINISHED'}

        return {'CANCELLED'}
예제 #5
0
    def execute(self, context):
        n = context.active_node
        fpath = self.get_filepath_from_node(n)
        string_dir = remapper.get(n.bl_idname)

        with sv_preferences() as prefs:

            if prefs.real_sverchok_path:
                _dst = os.path.dirname(sverchok.__file__)
                _src = prefs.real_sverchok_path
                fpath = fpath.replace(_dst, _src)

            if self.kind == 'internal':
                self.view_source_internal(context.screen.areas, fpath)

            elif self.kind == 'external':
                self.view_source_external(prefs, fpath)

            return {'FINISHED'}

        return {'CANCELLED'}