code: def build_doc(cls, **kwargs):
      """Decorator to build docstrings for datalad commands
  
      It's intended to decorate the class, the __call__-method of which is the
      actual command. It expects that __call__-method to be decorated by
      eval_results.
  
      Note that values for any `eval_params` keys in `cls._params_` are
      ignored.  This means one class may extend another's `_params_`
      without worrying about filtering out `eval_params`.
  
      Parameters
      ----------
      cls: Interface
        DataLad command implementation
      """
      if datalad.in_librarymode():
          lgr.debug("Not assembling DataLad API docs in libary-mode")
          return cls
  
      # Note, that this is a class decorator, which is executed only once when the
      # class is imported. It builds the docstring for the class' __call__ method
      # and returns the original class.
      #
      # This is because a decorator for the actual function would not be able to
      # behave like this. To build the docstring we need to access the attribute
      # _params of the class. From within a function decorator we cannot do this
      # during import time, since the class is being built in this very moment and
      # is not yet available in the module. And if we do it from within the part
      # of a function decorator, that is executed when the function is called, we
      # would need to actually call the command once in order to build this
      # docstring.
  
      lgr.debug("Building doc for %s", cls)
  
      cls_doc = cls.__doc__
      if hasattr(cls, "_docs_"):
          # expand docs
          cls_doc = cls_doc.format(**cls._docs_)
      # get examples
      ex = getattr(cls, "_examples_", [])
      if ex:
          cls_doc = update_docstring_with_examples(cls_doc, ex)
  
      call_doc = None
      # suffix for update_docstring_with_parameters:
      if cls.__call__.__doc__:
          call_doc = cls.__call__.__doc__
  
      # build standard doc and insert eval_doc
      spec = getattr(cls, "_params_", dict())
  
      # update class attributes that may override defaults
      if not _has_eval_results_call(cls):
          add_args = None
      else:
          # defaults for all common parameters are guaranteed to be available
          # from the class
          add_args = {k: getattr(cls, k) for k in eval_params}
  
      # ATTN: An important consequence of this update() call is that it
      # fulfills the docstring's promise of overriding any existing
      # values for eval_params keys in _params_.
      #
  
      # get docs for eval_results parameters:
      spec.update(eval_params)
  
      update_docstring_with_parameters(
          cls.__call__,
          spec,
          prefix=alter_interface_docs_for_api(cls_doc),
          suffix=alter_interface_docs_for_api(call_doc),
          add_args=add_args,
      )
  
      if hasattr(cls.__call__, "_dataset_method"):
          cls.__call__._dataset_method.__doc__ = cls.__call__.__doc__
  
      # return original
      return cls
  
imports: import inspect
  import logging
  import os
  import re
  import textwrap
  import warnings
  from abc import ABC, abstractmethod
  from functools import wraps
  from importlib import import_module
  from typing import Callable, Dict, Generator, TypeVar, TYPE_CHECKING
  import datalad
  from datalad import cfg
  from datalad.core.local.resulthooks import get_jsonhooks_from_config, match_jsonhook2result, run_jsonhook
  from datalad.distribution.dataset import Dataset, resolve_path
  from datalad.interface.common_opts import eval_params
  from datalad.interface.results import known_result_xfms
  from datalad.interface.utils import get_result_filter, keep_result, render_action_summary, xfm_result, _process_results
  from datalad.support.exceptions import CapturedException, IncompleteResultsError
  from datalad.utils import get_wrapped_class
label_desc: Use image node_id 12 for calling a global function with example usage: build_doc(cls) and returns: cls, cls