Skip to content

Commit

Permalink
docs: added code documentation to theme module
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 1f68705dcb54cfdf7b675ae0f289e1518800d51894c4c7dea39e95fd27674be0
  • Loading branch information
thindil committed Dec 4, 2023
1 parent 3a42a10 commit 0b52400
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/theme.nim
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ proc newColor*(name: string = ""; cValue: ColorName = default;

proc showThemeError(message: string; e: ref Exception) {.sideEffect, raises: [],
tags: [WriteIOEffect, RootEffect], contractual.} =
## Show the information about the error related to the theme. The theme's
## module uses the separated code, to avoid circular dependencies and eternal
## errors.
##
## * message - the message to show to the user
## * e - the exception which happened
require:
message.len > 0
e != nil
Expand Down Expand Up @@ -154,14 +160,20 @@ proc createThemeDb*(db): ResultCode {.sideEffect, raises: [], tags: [

proc getColor*(db; name: string): string {.sideEffect, raises: [], tags: [
ReadDbEffect, WriteIOEffect, RootEffect], contractual.} =
## Get the selected the shell's theme's color.
##
## * db - the connection to the shell's database
## * name - the name of the color to get
##
## Returns the terminal code related to the selected theme's color
require:
name.len > 0
body:
var color: Color = newColor(cValue = red)
if db == nil:
return termRed
try:
db.select(obj = color, "name=?", name)
db.select(obj = color, cond = "name=?", params = name)
except:
showThemeError(message = "Can't get the shell's theme color: '" & name &
"'. Reason: ", e = getCurrentException())
Expand Down

0 comments on commit 0b52400

Please sign in to comment.