Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozhidar Batsov committed Jun 3, 2013
0 parents commit 83410fe
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
@@ -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
28 changes: 28 additions & 0 deletions README.md
@@ -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.
6 changes: 6 additions & 0 deletions project.clj
@@ -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)
27 changes: 27 additions & 0 deletions src/leiningen/annotations.clj
@@ -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)))

0 comments on commit 83410fe

Please sign in to comment.