class_docstr: Original :doc: role throws away all the format, and keep raw text only.
  We wish to keep module names literal. This patch is to keep literal format in :doc: resolver.
class_docstr_tok: ["Original",":","doc",":","role","throws","away","all","the","format",",","and","keep","raw","text","only",".","We","wish","to","keep","module","names","literal",".","This","patch","is","to","keep","literal","format","in",":","doc",":","resolver","."]
code: def patch(self, *args, **kwargs):
      self.original = (
          sphinx.domains.std.StandardDomain._resolve_doc_xref
      )
  
      def doc_xref_resolver(
          std_domain,
          env,
          fromdocname,
          builder,
          typ,
          target,
          node,
          contnode,
      ):
          if not node.get("refkeepformat"):
              # redirect to original implementation to make it safer
              return self.original(
                  std_domain,
                  env,
                  fromdocname,
                  builder,
                  typ,
                  target,
                  node,
                  contnode,
              )
  
          # directly reference to document by source name; can be absolute or relative
          from sphinx.domains.std import docname_join, make_refnode
  
          refdoc = node.get("refdoc", fromdocname)
          docname = docname_join(refdoc, node["reftarget"])
          if docname not in env.all_docs:
              return None
          else:
              innernode = node[
                  0
              ]  # no astext here, to keep literal intact
              return make_refnode(
                  builder, fromdocname, docname, None, innernode
              )
  
      sphinx.domains.std.StandardDomain._resolve_doc_xref = (
          doc_xref_resolver
      )
  
file_path: nni/docs/extension/patch_autodoc.py
imports: import inspect
  import os
  from typing import List, Tuple, List
  import sphinx
  from docutils import nodes
  from docutils.nodes import Node
label_desc: Use image node_id 2 for calling the ResolveDocPatch obj's underlying member method code with example usage: obj.patch() and returns: self, None, make_refnode