On this page:
bridge
Space  Name
Context
set
set_  group
adjust_  term
adjust_  group
adjust_  sequence
adjust_  multi
adjust_  block
8.15.0.2

3.5 Code Binding-Space Adjusters🔗ℹ

 import: scribble/spacer package: rhombus-scribble-lib

A spacer is a compile-time function that is used by forms like rhombus to determine how names within a typeset form should be linked to documentation. For example, :: in some contexts should be linked to the :: expression operator, and in other contexts to the :: binding operator. In general, typeset code cannot be executed or expanded to determine those bindings. Instead, links are determined by a combination of meta_label imports and spacer-applied properties. Spacers thus provide an approximate and best-effort attempt to properly link names in documentation.

definition

bridge name(self_id, tail_id, context_id, esc_id):

  ~in: space ...

  body

  ...

Binds name in the typesetting space to a function that specifies space choices for terms within a name form. For example, fun is bound to a function that (along other things) looks for a result annotation in a fun form and specifies that the annotation is in the #'~annot space. The spacing function will be used only when name itself is in one of the spaces named by a space, where each space is either a keyword for a built-in space (such as #'~annot; see rhombus) or a symbol naming a space.

The body result should be a syntax object like '$self_id $tail_id', but where space properties are added within self_id and tail_id via functions like set and adjust_term. Take care to preserve syntax locations and properties via Syntax.relocate when reconstructing syntax objects; functions like adjust_term use Syntax.relocate automatically, but can obviously only cover the given syntax object.

The context_id argument will be a keyword, symbol, or list of symbols corresponding to one of the spaces. The spacer’s behavior might depend on that context, but often it’s passed along as-is to functions like set or adjust_group.

The esc_id argument is an identifier or operator syntax object that specifies an escape operator, such as #,. Spacing should general not traverse into escaped forms.

annotation

SpaceName

 

annotation

Context

A SpaceName represents a space as a symbol, keyword for a built-in space (see rhombus), or #false for the expr space. A Context is a SpaceName, list of SpaceNames, or pair list of SpaceNames.

A Context represents one or more spaces for recording as a property or adding further space annotations. When a Context is a list to be recorded in a property, space symbols in the list will be tried first to last to look for link-target bindings within each space.

function

fun set(stx :: TermSequence, context :: Context) :: Sequence

 

function

fun set_group(stx :: Group, context :: Context) :: Group

Returns a syntax object like stx, but with properties to specify that it should be rendered as being in the space indicated by context.

function

fun adjust_term(stx :: Term, context :: Context, esc :: Name)

  :: Syntax

 

function

fun adjust_group(stx :: Group, context :: Context, esc :: Name)

  :: Syntax

 

function

fun adjust_sequence(stx :: TermSequence, context :: Context,

                    esc :: Name)

  :: Syntax

 

function

fun adjust_multi(stx :: Syntax, context :: Context, esc :: Name)

  :: Syntax

 

function

fun adjust_block(stx :: Block, context :: Context, esc :: Name)

  :: Syntax

Similar to set, but recursively finds and applies spacers within stx according to the given context, passing along esc to nested spacers so that they can avoid traversing escape sequences.