docs: def register_formatter(field_typestr):
      """Decorate a configuration field formatter function to register it with
      the `get_field_formatter` accessor.
  
      This decorator also performs common helpers for the formatter functions:
  
      - Does type checking on the field argument passed to a formatter.
      - Assembles a section node from the nodes returned by the formatter.
      """
      def decorator_register(formatter):
  
          @functools.wraps(formatter)
          def wrapped_formatter(*args, **kwargs):
              field_name = args[0]
              field = args[1]
              field_id = args[2]
  
              # Before running the formatter, do type checking
              field_type = get_type(field_typestr)
              if not isinstance(field, field_type):
                  message = ('Field {0} ({1!r}) is not an '
                             '{2} type. It is an {3}.')
                  raise ValueError(
                      message.format(field_name, field, field_typestr,
                                     typestring(field)))
  
              # Run the formatter itself
              nodes = formatter(*args, **kwargs)
  
              # Package nodes from the formatter into a section
              section = make_section(
                  section_id=field_id + '-section',
                  contents=nodes)
              return section
  
          FIELD_FORMATTERS[field_typestr] = wrapped_formatter
  
          return wrapped_formatter
      return decorator_register