Skip to content

Commit

Permalink
Mention the importance of semantic names in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed May 12, 2024
1 parent 0be209b commit 6901610
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ styled"{(underline=warning):this is some minor/slight warning text}"
styled"A very major {(fg=error,bg=warning),bold:warning!}"
```

!!! tip "Focus on semantics, and let style follow"
Note that when using faces, it is generally recommended to focus on the
*semantic intent*, not the specific styling (`cyan`, `bold`, etc.),
introducing new faces when there is no pre-existing semantically appropriate
face.

## Inline face attributes

Should you want to use a particular color just once, the `foreground`/`fg` and `background`/`bg` inline face attributes can be set to hex codes.
Expand Down
10 changes: 8 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ easily [customized](@ref stdlib-styledstrings-face-toml).
by the package name, i.e. follow the format `mypackage_myface`.
This is important for predictability, and to prevent name clashes.

There is one set of exemptions to the package-prefix rule, the set of basic
faces that are part of the default value of the faces dictionary.
Furthermore, packages should take care to use (and introduce) *semantic*
faces (like `code`) over direct colours and styles (like `cyan`). This is helpful
in a number of ways, from making the intent in usage more obvious, aiding
composability, and making user customisation more intuitive.

There are two set of exemptions to the package-prefix rule:
- the set of basic faces that are part of the default value of the faces dictionary
- faces introduced by Julia's own standard library, namely `JuliaSyntaxHighlighting`

#### [Basic faces](@id stdlib-styledstrings-basic-faces)

Expand Down

0 comments on commit 6901610

Please sign in to comment.