Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bozhidar Batsov
committed
Jun 3, 2013
0 parents
commit 83410fe
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
pom.xml.asc | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins | ||
.lein-repl-history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# lein-annotations | ||
|
||
A Leiningen plugin to display all comment annotations(`TODO`, `FIXME`, | ||
`OPTIMIZE`, etc) in your Clojure project. | ||
|
||
It's inspired by the similar `rake notes` functionality available in Ruby on Rails. | ||
|
||
## Usage | ||
|
||
Put `[lein-annotations "0.1.0-SNAPSHOT"]` into the `:plugins` vector | ||
of your `project.clj`. | ||
|
||
Afterwards just run: | ||
|
||
$ lein annotations | ||
|
||
You'll see a summary like: | ||
|
||
``` | ||
test.clj: 8: ;; FIXME this blows up from time to time | ||
test.clj: 11: ;; OPTIMIZE this is doing a lot of useless computations light now | ||
``` | ||
|
||
## License | ||
|
||
Copyright © 2013 Bozhidar Batsov | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(defproject lein-annotations "0.1.0-SNAPSHOT" | ||
:description "Displays all comment annotations in the project." | ||
:url "http://github.com/bbatsov/lein-annotations" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:eval-in-leiningen true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns leiningen.annotations | ||
(:require (clojure [string :as str]) | ||
[clojure.java.io :as io])) | ||
|
||
(defn- project-files | ||
"Obtain a list of all Clojure files in the current project." | ||
[project-dir] | ||
(filter #(.endsWith (.getName %) ".clj") | ||
(file-seq (io/file project-dir)))) | ||
|
||
(defn- relative-path | ||
"Obtain relative path to file." | ||
[root file] | ||
(str/replace-first (.getAbsolutePath file) (str root java.io.File/separator) "")) | ||
|
||
(defn- process-file | ||
"Looks for comment annotations in file." | ||
[root file] | ||
(doseq [[line-num line] (map-indexed vector (line-seq (io/reader file)))] | ||
(when (re-find #";+\s*(TODO|FIXME|OPTIMIZE)" line) | ||
(println (format "%s:%3d: %s" (relative-path root file) (inc line-num) line))))) | ||
|
||
(defn annotations | ||
"Display comment annotations in the current project." | ||
[project & args] | ||
(doseq [file (project-files (:root project))] | ||
(process-file (:root project) file))) |