Changes between Version 25 and Version 26 of Clojure Client Tutorial


Ignore:
Timestamp:
Aug 4, 2011 3:26:07 PM (13 years ago)
Author:
kedwar10
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Clojure Client Tutorial

    v25 v26  
    1212
    1313You could skip this step but it will less convenient later on for debugging.
    14 
    15 Once you have lieningen setup, cd to the client directory and type "tree" into the shell.
    16 
    17 This organization is the default for the leiningen projects created with the "lein new <myprojectname>" command.
    18 
    19 docs contains and html file that provides a sort of annotated presentation of the code.  Read this file first to familiarize yourself with the organization of the project. Once you have made your own changes to the client and wish to update the documentation, run "lein marg" in the top level directory.  This invokes the marginalia jar in the lib directory and generates a new html file.
    20 
    21 In the top level directory there is a file called "project.clj". This file tells leiningen how your project is organized.  For details, consult the tutorial, but know that if you wish to add additional clojure libraries to your project, you will need to specify them here, and run "lein deps" to download them.  Specific directions for leiningen are provided nearly universally for clojure project, so just look them up as needed.
    22 
    23 src contains all of the clj files in your project.  The organization of the directory must correspond to the namespaces of your project so edit with care (more on this later, but one thing to note is that if you have a namespace with dash in it, "client.my-ns", for example, the actual filename must be "my_ns.clj" and it must be located in the client directory).
    24 
    25 test contains files that leiningen will use for testing your functions via the "lein test" command.  This functionality is not critical in clojure since you can debug easily from the REPL, but if you want to batch test functions then you can look into this.
    26 
    27 When you create a new project with leiningen, it will automatically provide a core.clj file for you.  If your namespaces are organized into a tree, this is the root.  When you run the REPL in the top level directory via the "lein repl" command, the core namspace becomes available to you.  This is why having leiningen on your path is useful, as you won't always want to load the core namespace.  An important detail: namespaces must NOT be cyclic in clojure, so plan accordingly when designing your project.
    2814
    2915At this point I recommend reading "Joy of Clojure", by Michael Fogus and Chris Houser. This is an excellent introduction to clojure if you are already familiar with lisp or scheme.  Much of the inspiration for this client comes from this book so if you're having trouble figuring out what is going on, this will provide most of the background you will need.  If you're short on time or funds, just search for online tutorials, there are plenty out there.  If you need to quickly look up the documentation on any particular function, just type "(doc f)" in the REPL where f is the function (This will also work for functions that you define provided that you wrote docstrings or added meta-data).
     
    4430
    4531== Overview of Code ==
     32
     33Once you have lieningen setup, cd to the client directory and type "tree" into the shell.
     34
     35This organization is the default for the leiningen projects created with the "lein new <myprojectname>" command.
     36
     37docs contains and html file that provides a sort of annotated presentation of the code.  Read this file first to familiarize yourself with the organization of the project. Once you have made your own changes to the client and wish to update the documentation, run "lein marg" in the top level directory.  This invokes the marginalia jar in the lib directory and generates a new html file.
     38
     39In the top level directory there is a file called "project.clj". This file tells leiningen how your project is organized.  For details, consult the tutorial, but know that if you wish to add additional clojure libraries to your project, you will need to specify them here, and run "lein deps" to download them.  Specific directions for leiningen are provided nearly universally for clojure project, so just look them up as needed.
     40
     41src contains all of the clj files in your project.  The organization of the directory must correspond to the namespaces of your project so edit with care (more on this later, but one thing to note is that if you have a namespace with dash in it, "client.my-ns", for example, the actual filename must be "my_ns.clj" and it must be located in the client directory).
     42
     43test contains files that leiningen will use for testing your functions via the "lein test" command.  This functionality is not critical in clojure since you can debug easily from the REPL, but if you want to batch test functions then you can look into this.
     44
     45When you create a new project with leiningen, it will automatically provide a core.clj file for you.  If your namespaces are organized into a tree, this is the root.  When you run the REPL in the top level directory via the "lein repl" command, the core namspace becomes available to you.  This is why having leiningen on your path is useful, as you won't always want to load the core namespace.  An important detail: namespaces must NOT be cyclic in clojure, so plan accordingly when designing your project.
    4646
    4747----