diff --git a/TODO.md b/TODO.md index e4b6807..049a451 100644 --- a/TODO.md +++ b/TODO.md @@ -68,10 +68,6 @@ To see what's happening in a section, click on the arrow symbol (▶). ## In Progress...
- -- [ ] Create the `_23_metaprogramming.jl` file: - [`metaprogramming`](https://github.com/udohjeremiah/REPLference.jl/tree/metaprogramming) - [@udohjeremiah](https://github.com/udohjeremiah)
## Done ✓ @@ -84,4 +80,6 @@ To see what's happening in a section, click on the arrow symbol (▶). - [x] Create the `.JuliaFormatter.jl` file and use `BlueStyle`: [`#60`](https://github.com/udohjeremiah/REPLference.jl/pull/60) [@udohjeremiah](https://github.com/udohjeremiah) +- [x] Create the `_23_metaprogramming.jl` file: + [`#64`](https://github.com/udohjeremiah/REPLference.jl/pull/64) diff --git a/src/REPLference.jl b/src/REPLference.jl index 5ffda05..e9dcaad 100644 --- a/src/REPLference.jl +++ b/src/REPLference.jl @@ -23,6 +23,7 @@ include("_19_module.jl") include("_20_regex.jl") include("_21_date.jl") include("_22_random.jl") +include("_23_metaprogramming.jl") import Dates: AbstractTime import .Docs: doc @@ -76,136 +77,142 @@ function subtree end function man(obj::Symbol) str = string(obj) # keywords - if match(r"^(?:keyword|reserved)"i, str) != nothing + if match(r"^(?:keyword|reserved)"i, str) !== nothing doc(keywords) # variables - elseif match(r"^variable"i, str) != nothing + elseif match(r"^variable"i, str) !== nothing doc(variables) # operators - elseif match(r"^operat(?:or|ion)"i, str) != nothing + elseif match(r"^operat(?:or|ion)"i, str) !== nothing doc(operators) # integers - elseif match(r"^integer"i, str) != nothing + elseif match(r"^integer"i, str) !== nothing doc(integers) # floating points - elseif match(r"^float"i, str) != nothing + elseif match(r"^float"i, str) !== nothing doc(floats) # complex numbers - elseif match(r"^complex"i, str) != nothing + elseif match(r"^complex"i, str) !== nothing doc(complexs) # rational numbers - elseif match(r"^rational"i, str) != nothing + elseif match(r"^rational"i, str) !== nothing doc(rationals) # irrationals - elseif match(r"^irrational"i, str) != nothing + elseif match(r"^irrational"i, str) !== nothing doc(irrationals) # characters - elseif match(r"^character"i, str) != nothing + elseif match(r"^character"i, str) !== nothing doc(characters) # strings - elseif match(r"^string"i, str) != nothing + elseif match(r"^string"i, str) !== nothing doc(strings) # ranges - elseif match(r"^range"i, str) != nothing + elseif match(r"^range"i, str) !== nothing doc(ranges) # arrays - elseif match(r"^array"i, str) != nothing + elseif match(r"^array"i, str) !== nothing doc(arrays) # tuples - elseif match(r"^(?:tuple|named(.)?tuple)"i, str) != nothing + elseif match(r"^(?:tuple|named(.)?tuple)"i, str) !== nothing doc(tuples) # dictionaries - elseif match(r"^dict"i, str) != nothing + elseif match(r"^dict"i, str) !== nothing doc(dicts) # sets - elseif match(r"^set"i, str) != nothing + elseif match(r"^set"i, str) !== nothing doc(sets) # types - elseif match(r"^(?:type|datatype)"i, str) != nothing + elseif match(r"^(?:type|datatype)"i, str) !== nothing doc(types) # function - elseif match(r"^(?:function|method|procedure)"i, str) != nothing + elseif match(r"^(?:function|method|procedure)"i, str) !== nothing doc(functions) # files - elseif match(r"^(?:file|io|stream)"i, str) != nothing + elseif match(r"^(?:file|io|stream)"i, str) !== nothing doc(files) # modules - elseif match(r"^(?:module|package)"i, str) != nothing + elseif match(r"^(?:module|package)"i, str) !== nothing doc(modules) # regexes - elseif match(r"^reg(?:ex|ular)"i, str) != nothing + elseif match(r"^reg(?:ex|ular)"i, str) !== nothing doc(regexes) # time and date - elseif match(r"^(?:time|date)"i, str) != nothing + elseif match(r"^(?:time|date)"i, str) !== nothing doc(datetime) # random numbers - elseif match(r"^rand"i, str) != nothing + elseif match(r"^rand"i, str) !== nothing doc(randoms) + # metaprogramming + elseif match(r"^meta"i, str) !== nothing + doc(metaprogramming) end end function fun(obj::Symbol; extmod=false) str = string(obj) # operators - if match(r"operat(?:or|ion)"i, str) != nothing + if match(r"operat(?:or|ion)"i, str) !== nothing operators(; extmod=extmod) # integers - elseif match(r"^integer"i, str) != nothing + elseif match(r"^integer"i, str) !== nothing integers(; extmod=extmod) # floating points - elseif match(r"^float"i, str) != nothing + elseif match(r"^float"i, str) !== nothing floats(; extmod=extmod) # complex numbers - elseif match(r"^complex"i, str) != nothing + elseif match(r"^complex"i, str) !== nothing complexs(; extmod=extmod) # rational numbers - elseif match(r"^rational"i, str) != nothing + elseif match(r"^rational"i, str) !== nothing rationals(; extmod=extmod) # irrationals - elseif match(r"^irrational"i, str) != nothing + elseif match(r"^irrational"i, str) !== nothing irrationals(; extmod=extmod) # characters - elseif match(r"^character"i, str) != nothing + elseif match(r"^character"i, str) !== nothing characters(; extmod=extmod) # strings - elseif match(r"^string"i, str) != nothing + elseif match(r"^string"i, str) !== nothing strings(; extmod=extmod) # ranges - elseif match(r"^range"i, str) != nothing + elseif match(r"^range"i, str) !== nothing ranges(; extmod=extmod) # arrays - elseif match(r"^array"i, str) != nothing + elseif match(r"^array"i, str) !== nothing arrays(; extmod=extmod) # tuples - elseif match(r"^(?:tuple|named(.)?tuple)"i, str) != nothing + elseif match(r"^(?:tuple|named(.)?tuple)"i, str) !== nothing tuples(; extmod=extmod) # dictionaries - elseif match(r"^dict"i, str) != nothing + elseif match(r"^dict"i, str) !== nothing dicts(; extmod=extmod) # sets - elseif match(r"^set"i, str) != nothing + elseif match(r"^set"i, str) !== nothing sets(; extmod=extmod) # types - elseif match(r"^(?:type|datatype)"i, str) != nothing + elseif match(r"^(?:type|datatype)"i, str) !== nothing types() # function - elseif match(r"^(?:function|method|procedure)"i, str) != nothing + elseif match(r"^(?:function|method|procedure)"i, str) !== nothing functions(; extmod=extmod) # files - elseif match(r"^(?:file|io|stream)"i, str) != nothing + elseif match(r"^(?:file|io|stream)"i, str) !== nothing files(; extmod=extmod) # modules - elseif match(r"^(?:module|package)"i, str) != nothing + elseif match(r"^(?:module|package)"i, str) !== nothing modules(; extmod=extmod) # regexes - elseif match(r"^re(?:gex|gular)"i, str) != nothing + elseif match(r"^re(?:gex|gular)"i, str) !== nothing regexes(; extmod=extmod) # time and date - elseif match(r"^(?:time|date)"i, str) != nothing + elseif match(r"^(?:time|date)"i, str) !== nothing datetime(; extmod=extmod) # random numbers - elseif match(r"^rand"i, str) != nothing + elseif match(r"^rand"i, str) !== nothing randoms(; extmod=extmod) + # metaprogramming + elseif match(r"^meta"i, str) !== nothing + metaprogramming(; extmod=extmod) end end diff --git a/src/_23_metaprogramming.jl b/src/_23_metaprogramming.jl index dfc1a9a..6834394 100644 --- a/src/_23_metaprogramming.jl +++ b/src/_23_metaprogramming.jl @@ -1740,7 +1740,7 @@ function metaprogramming(; extmod=false) ] types = ["Types" => ["DataType", "Expr", "Meta.ParseErrorˣ", "QuoteNode", "Symbol"]] operators = ["Operators" => [":"]] - stdlib => ["Stdlib" => ["Printf.@printf", "Printf.@sprintf"]] + stdlib = ["Stdlib" => ["Printf.@printf", "Printf.@sprintf"]] _print_names(macros, methods, types, operators) if extmod == true _print_names(stdlib) diff --git a/test/runtests.jl b/test/runtests.jl index 6d51bdc..63b1419 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -40,6 +40,7 @@ using Test @test typeof(man(:regex)) === Markdown.MD @test typeof(man(:time)) === Markdown.MD @test typeof(man(:random)) === Markdown.MD + @test typeof(man(:meta)) === Markdown.MD @test man(:keywords) == man(:reserved) @test man(:operators) == man(:operations) @@ -72,6 +73,7 @@ using Test @test fun(:files) === nothing @test fun(:modules) === nothing @test fun(:regex) === nothing + @test fun(:meta) === nothing @test fun(:keywords) == fun(:reserved) @test fun(:operators) == fun(:operations) @@ -104,6 +106,7 @@ using Test @test fun(:files; extmod=true) === nothing @test fun(:modules; extmod=true) === nothing @test fun(:regex; extmod=true) === nothing + @test fun(:meta; extmod=true) === nothing @test subtree(Number) === nothing @test subtree(Vector) === nothing