Skip to content

Commit

Permalink
docs(CONTRIBUTING): describe naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 27, 2025
1 parent ac484b5 commit 2651f35
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,44 @@ commits for respective purposes. On the other hand, PRs including several
minor fixes to the exiting codebase will not be squashed because each commit
gives a separate fix to the exiting code.

### Naming convention of functions and global variables

Initially, we haven't cared about the naming convention very much, but we now
try to improve it. In particular, the new codes should follow this naming
convention. The contributions to improve old codes are also welcome, but we
also need to keep the backward compatibility. See [Discussion
#280](https://github.com/ohmybash/oh-my-bash/discussions/280) for background.

The functions/aliases that are supposed to be used as interactive commands can
have arbitrary names including short ones.

The functions that are used from the other functions have the names of the form
`_omb_*`.

* The functions defined by libraries has the form `_omb_${namespace}_${funcname}`
* The functions defined by a specific plugin has the form `_omb_plugin_${plugin_name}_${funcname}`
* The functions defined by a specific theme has the form `_omb_theme_${theme_name}_${funcname}`
* Some important functions might have the name `_omb_${funcname}` directly put under `_omb` namespace.

Public global variables that can be used to configure the behavior of
oh-my-bash have the form `OMB_*`.

* The settings for the main oh-my-bash behavior have the names of the form `OMB_${config^^}`
* The settings for the detailed behavior have the names of the form `OMB_${namespace^^}_${config^^}`
* The settings for a specific plugin has the form `OMB_PLUGIN_${plugin_name^^}_${config^^}`
* The settings for a specific theme has the form `OMB_THEME_${theme_name^^}_${config^^}`

Internal global variables put into global variables used by oh-my-bash has the form `_omb_*`

* The internal variables defined by libraries has the form `_omb_${namespace}_${varname}`
* The internal variables used by a specific plugin has the form `_omb_plugin_${plugin_name}_${varname}`
* The internal variables used by a specific theme has the form `_omb_theme_${theme_name}_${varname}`
* Some important variables might have the name `_omb_${varname}` directly put under `_omb` namespace.

There are no restrictions on the local variable names. A prefix like
`_omb_${namespace}_` is unnecessary because the namespace of the local
variables is separated for each function call.

----

## Use the Search, Luke
Expand Down

0 comments on commit 2651f35

Please sign in to comment.