@@ -45,6 +45,15 @@ function _replace_in_files_recursive(path, replacement; ignore_dirs, showdiffs)
4545 return nothing
4646end
4747
48+ """
49+ replace_in_files(path::String, replacement::Pair{String,String}; ignore_dirs=[], recursive=false, showdiffs=true)
50+
51+ # Examples
52+
53+ ```julia
54+ replace_in_files(".", "@show" => "@test"; recursive=true, ignore_dirs=[".git"])
55+ ```
56+ """
4857function replace_in_files (path, replacement; ignore_dirs= [], recursive= false , showdiffs= true )
4958 if recursive
5059 _replace_in_files_recursive (path, replacement; ignore_dirs= ignore_dirs, showdiffs= showdiffs)
@@ -55,8 +64,17 @@ function replace_in_files(path, replacement; ignore_dirs=[], recursive=false, sh
5564 return nothing
5665end
5766
58- function map_filenames (f, path= pwd (); filter= Returns (true ), force= false )
59- files = Base. filter (filter, readdir (path))
67+ """
68+ map_filenames(f::Function, path=pwd(); filter_filenames=Returns(true), force=false)
69+
70+ # Examples
71+
72+ ```julia
73+ map_filenames(filename -> replace(filename, ".txt" => ".txt.backup"); filter_filenames=startswith("example_"))
74+ ```
75+ """
76+ function map_filenames (f, path= pwd (); filter_filenames= Returns (true ), force= false )
77+ files = Base. filter (filter_filenames, readdir (path))
6078 for (i, file) in enumerate (files)
6179 old_filename = joinpath (path, file)
6280 new_filename = joinpath (path, f (file))
@@ -68,6 +86,15 @@ function map_filenames(f, path=pwd(); filter=Returns(true), force=false)
6886 return nothing
6987end
7088
89+ """
90+ replace_filenames(path=pwd(), replacement::Pair{String,String}; filter=Returns(true), force=false)
91+
92+ # Examples
93+
94+ ```julia
95+ replace_filenames(pwd(), ".txt" => ".txt.backup")
96+ ```
97+ """
7198function replace_filenames (replacement, args... ; kwargs... )
7299 return map_filenames (file -> replace (file, replacement), args... ; kwargs... )
73100end
@@ -82,6 +109,15 @@ function max_version(depot_path::AbstractString, pkgname::AbstractString)
82109 return v " 0.0.0"
83110end
84111
112+ """
113+ max_version(pkgname)
114+
115+ # Examples
116+
117+ ```julia
118+ max_version("ITensors")
119+ ```
120+ """
85121max_version (pkgname:: AbstractString ) = maximum (max_version .(DEPOT_PATH , pkgname))
86122
87123end
0 commit comments