コード例 #1
0
ファイル: hsearch.py プロジェクト: mchaput/bookish
    def _should_index_document(self, pages, path, root, block):
        # Hide nodes that are hidden or superceded
        # Only do this test at the top level (not for every sub-doc)
        if path.startswith("/nodes/") and block is root:
            # See if we can turn the path into a nodetype using HOM
            nodetype = path_to_nodetype(path)
            if nodetype:
                if nodetype.hidden() or nodetype.deprecated():
                    return False

                # Check if the node has been superseded by a more recent version
                order = nodetype.namespaceOrder()
                if order and nodetype.name() != order[0]:
                    return False

        rootattrs = root.get("attrs")
        pagetype = rootattrs.get("type") if rootattrs else None
        attrs = block.get("attrs")
        blocktype = block.get("type")

        if attrs and attrs.get("status") in ("ni", "nd"):
            return False

        # Recognize Houdini-specific sub-documents
        if blocktype in ("methods_item", "functions_item"):
            return True
        if blocktype == "properties_item" and pagetype == "properties":
            return True

        parent = super(HoudiniSearchables, self)
        return parent._should_index_document(pages, path, root, block)
コード例 #2
0
ファイル: hstores.py プロジェクト: mchaput/bookish
 def exists(self, path):
     nodetype = api.path_to_nodetype(path)
     if nodetype and not nodetype.hidden():
         hdadef = nodetype.definition()
         info = api.path_to_components(path)
         if hdadef:
             return (
                 (path.endswith(".txt") and hdadef.embeddedHelp()) or
                 (info.section and info.section in hdadef.section())
             )
コード例 #3
0
ファイル: hstores.py プロジェクト: mchaput/bookish
    def delete(self, path):
        nodetype = api.path_to_nodetype(path)
        if nodetype:
            hdadef = nodetype.definition()
            if not hdadef:
                raise Exception("%r is not an asset" % path)

            info = api.path_to_components(path)
            section = info.section or "Help"
            if hdadef:
                hdadef.sections()[section].setContents("")
コード例 #4
0
ファイル: hstores.py プロジェクト: mchaput/bookish
    def write_file(self, path, bytestring):
        nodetype = api.path_to_nodetype(path)
        if nodetype:
            hdadef = nodetype.definition()
            if not hdadef:
                raise Exception("%r is not an asset" % path)

            info = api.path_to_components(path)
            sections = hdadef.sections()
            section = info.section or "Help"
            if section in sections:
                sections[section].setContents(bytestring)
            else:
                hdadef.addSection(section, bytestring)
コード例 #5
0
ファイル: hstores.py プロジェクト: mchaput/bookish
 def _path_to_hdadef(path):
     nodetype = api.path_to_nodetype(path)
     if nodetype:
         return nodetype.definition()