Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4bf3e1c7c1 | |||
2d62dee4d0 | |||
3eb542bdfd | |||
5b87d0bf9a |
@@ -97,7 +97,7 @@ has some functions to work with the <code>PATH</code> environment variable.</p>
|
|||||||
</pre>
|
</pre>
|
||||||
<p class="doc">
|
<p class="doc">
|
||||||
<p>checks whether a path is absolute.</p>
|
<p>checks whether a path is absolute.</p>
|
||||||
<p>As such, it is the inverse to <a href="#relative">relative</a>.</p>
|
<p>As such, it is the inverse to <a href="#relative?">relative?</a>.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -342,7 +342,7 @@ is none.</p>
|
|||||||
</pre>
|
</pre>
|
||||||
<p class="doc">
|
<p class="doc">
|
||||||
<p>checks whether a path is relative.</p>
|
<p>checks whether a path is relative.</p>
|
||||||
<p>As such, it is the inverse to <a href="#absolute">absolute</a>.</p>
|
<p>As such, it is the inverse to <a href="#absolute?">absolute?</a>.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
15
gendocs.carp
15
gendocs.carp
@@ -1,13 +1,10 @@
|
|||||||
(load "path.carp")
|
(load "path.carp")
|
||||||
|
|
||||||
(defndynamic gendocs []
|
(Project.config "title" "path")
|
||||||
(do
|
(Project.config "docs-directory" "./docs/")
|
||||||
(Project.config "title" "path")
|
(Project.config "docs-logo" "")
|
||||||
(Project.config "docs-directory" "./docs/")
|
(Project.config "docs-styling" "style.css")
|
||||||
(Project.config "docs-logo" "")
|
(Project.config "docs-generate-index" false)
|
||||||
(Project.config "docs-styling" "style.css")
|
(save-docs Path)
|
||||||
(Project.config "docs-generate-index" false)
|
|
||||||
(save-docs Path)))
|
|
||||||
|
|
||||||
(gendocs)
|
|
||||||
(quit)
|
(quit)
|
||||||
|
12
path.carp
12
path.carp
@@ -16,7 +16,7 @@ It assumes either Windows or POSIX-style separators.")
|
|||||||
(defmodule Path
|
(defmodule Path
|
||||||
(doc absolute? "checks whether a path is absolute.
|
(doc absolute? "checks whether a path is absolute.
|
||||||
|
|
||||||
As such, it is the inverse to [relative](#relative).")
|
As such, it is the inverse to [relative?](#relative?).")
|
||||||
(doc separator "is the default separator we use on this OS.")
|
(doc separator "is the default separator we use on this OS.")
|
||||||
(doc separators "is the possible separators we could use on this OS.")
|
(doc separators "is the possible separators we could use on this OS.")
|
||||||
(doc search-path-separator "is the separator for the `PATH` environment
|
(doc search-path-separator "is the separator for the `PATH` environment
|
||||||
@@ -32,7 +32,7 @@ variable we use on this OS.")
|
|||||||
(def search-path-separator \;)
|
(def search-path-separator \;)
|
||||||
(def extension-pat #"\.[^\\/\.]*$")
|
(def extension-pat #"\.[^\\/\.]*$")
|
||||||
(def sep-string "\\"))
|
(def sep-string "\\"))
|
||||||
(not-on-windows
|
(posix-only
|
||||||
(defn absolute? [p] (String.starts-with? p "/"))
|
(defn absolute? [p] (String.starts-with? p "/"))
|
||||||
(def separator \/)
|
(def separator \/)
|
||||||
(def separators [\/])
|
(def separators [\/])
|
||||||
@@ -42,7 +42,7 @@ variable we use on this OS.")
|
|||||||
|
|
||||||
(doc relative? "checks whether a path is relative.
|
(doc relative? "checks whether a path is relative.
|
||||||
|
|
||||||
As such, it is the inverse to [absolute](#absolute).")
|
As such, it is the inverse to [absolute?](#absolute?).")
|
||||||
(defn relative? [p] (not (absolute? p)))
|
(defn relative? [p] (not (absolute? p)))
|
||||||
|
|
||||||
(doc separator? "checks whether the character `c` is a path separator on this
|
(doc separator? "checks whether the character `c` is a path separator on this
|
||||||
@@ -127,9 +127,9 @@ Examples on POSIX:
|
|||||||
(doc drop-extension "drops the extension of a path `p`. Does nothing if there
|
(doc drop-extension "drops the extension of a path `p`. Does nothing if there
|
||||||
is none.")
|
is none.")
|
||||||
(defn drop-extension [p]
|
(defn drop-extension [p]
|
||||||
@(match (split-extension p)
|
(match (split-extension p)
|
||||||
(Maybe.Nothing) p
|
(Maybe.Nothing) @p
|
||||||
(Maybe.Just pair) (Pair.a &pair)))
|
(Maybe.Just pair) @(Pair.a &pair)))
|
||||||
|
|
||||||
(doc add-extension "adds an extension `ext` to a path `p`.")
|
(doc add-extension "adds an extension `ext` to a path `p`.")
|
||||||
(defn add-extension [p ext] (String.concat &[@p @"." @ext]))
|
(defn add-extension [p ext] (String.concat &[@p @"." @ext]))
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
(use-all Path Test)
|
(use-all Path Test)
|
||||||
|
|
||||||
(if (not (Dynamic.or (= "windows" (os)) (= "mingw32" (os))))
|
(posix-only
|
||||||
(deftest test
|
(deftest test
|
||||||
(assert-equal test
|
(assert-equal test
|
||||||
"path/joined"
|
"path/joined"
|
||||||
@@ -41,11 +41,11 @@
|
|||||||
"cwd works"
|
"cwd works"
|
||||||
)
|
)
|
||||||
; TODO why does this test not work?
|
; TODO why does this test not work?
|
||||||
;(assert-equal test
|
(assert-equal test
|
||||||
; "file"
|
"file"
|
||||||
; &(drop-extension "file.txt")
|
&(drop-extension "file.txt")
|
||||||
; "drop-extension works if there is an extension"
|
"drop-extension works if there is an extension"
|
||||||
;)
|
)
|
||||||
(assert-equal test
|
(assert-equal test
|
||||||
"file"
|
"file"
|
||||||
&(drop-extension "file")
|
&(drop-extension "file")
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
())
|
())
|
||||||
(if (Dynamic.or (= "windows" (os)) (= "mingw32" (os)))
|
(windows-only
|
||||||
(deftest test
|
(deftest test
|
||||||
(assert-true test
|
(assert-true test
|
||||||
false
|
false
|
||||||
|
Reference in New Issue
Block a user