Skip to content

fix: make ansi examples from documentation executable #997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions doc/specs/stdlib_ansi.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,7 @@ Experimental
#### Example

```fortran
program demo_color
use stdlib_ansi, only : fg_color_blue, style_bold, style_reset, ansi_code, &
& operator(//), operator(+)
implicit none
type(ansi_code) :: highlight, reset

print '(a)', highlight // "Dull text message" // reset

highlight = fg_color_blue + style_bold
reset = style_reset

print '(a)', highlight // "Colorful text message" // reset
end program demo_color
{!example/ansi/example_ansi_color.f90!}
```


Expand Down Expand Up @@ -216,12 +204,7 @@ Experimental
#### Example

```fortran
program demo_string
use stdlib_ansi, only : fg_color_green, style_reset, to_string
implicit none

print '(a)', to_string(fg_color_green) // "Colorized text message" // to_string(style_reset)
end program demo_string
{!example/ansi/example_ansi_to_string.f90!}
```


Expand Down Expand Up @@ -255,13 +238,7 @@ Experimental
#### Example

```fortran
program demo_combine
use stdlib_ansi, only : fg_color_red, style_bold, ansi_code
implicit none
type(ansi_code) :: bold_red

bold_red = fg_color_red + style_bold
end program demo_combine
{!example/ansi/example_ansi_combine.f90!}
```


Expand Down Expand Up @@ -295,10 +272,5 @@ Experimental
#### Example

```fortran
program demo_concat
use stdlib_ansi, only : fg_color_red, style_reset, operator(//)
implicit none

print '(a)', fg_color_red // "Colorized text message" // style_reset
end program demo_concat
{!example/ansi/example_ansi_concat.f90!}
```
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ macro(ADD_EXAMPLE name)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endmacro(ADD_EXAMPLE)

add_subdirectory(ansi)
add_subdirectory(array)
add_subdirectory(ascii)
add_subdirectory(bitsets)
Expand Down
4 changes: 4 additions & 0 deletions example/ansi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ADD_EXAMPLE(ansi_color)
ADD_EXAMPLE(ansi_combine)
ADD_EXAMPLE(ansi_concat)
ADD_EXAMPLE(ansi_to_string)
13 changes: 13 additions & 0 deletions example/ansi/example_ansi_color.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
program example_ansi_color
use stdlib_ansi, only : fg_color_blue, style_bold, style_reset, ansi_code, &
& operator(//), operator(+)
implicit none
type(ansi_code) :: highlight, reset

print '(a)', highlight // "Dull text message" // reset

highlight = fg_color_blue + style_bold
reset = style_reset

print '(a)', highlight // "Colorful text message" // reset
end program example_ansi_color
9 changes: 9 additions & 0 deletions example/ansi/example_ansi_combine.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
program example_ansi_combine
use stdlib_ansi, only : fg_color_red, style_bold, ansi_code, operator(+), to_string
implicit none
type(ansi_code) :: bold_red

bold_red = fg_color_red + style_bold
print '(a)', to_string(bold_red)

end program example_ansi_combine
6 changes: 6 additions & 0 deletions example/ansi/example_ansi_concat.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
program example_ansi_concat
use stdlib_ansi, only : fg_color_red, style_reset, operator(//)
implicit none

print '(a)', fg_color_red // "Colorized text message" // style_reset
end program example_ansi_concat
6 changes: 6 additions & 0 deletions example/ansi/example_ansi_to_string.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
program example_ansi_to_string
use stdlib_ansi, only : fg_color_green, style_reset, to_string
implicit none

print '(a)', to_string(fg_color_green) // "Colorized text message" // to_string(style_reset)
end program example_ansi_to_string
Loading