-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to generate an AOT compatible Clojure namespace on…
… disk.
- Loading branch information
Showing
19 changed files
with
30,634 additions
and
112 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,37 @@ | ||
<!DOCTYPE html PUBLIC "" | ||
""> | ||
<html><head><meta charset="UTF-8" /><title>libpython-clj2.codegen documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="highlight/solarized-light.css" /><script type="text/javascript" src="highlight/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a> with <a href="https://github.com/xsc/codox-theme-rdash">RDash UI</a> theme</h2><h1><a href="index.html"><span class="project-title"><span class="project-name">libpython-clj</span> <span class="project-version">2.00-beta-4-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="Usage.html"><div class="inner"><span>Usage</span></div></a></li><li class="depth-1 "><a href="design.html"><div class="inner"><span>LibPython-CLJ Design Notes</span></div></a></li><li class="depth-1 "><a href="new-to-clojure.html"><div class="inner"><span>So Many Parenthesis!</span></div></a></li><li class="depth-1 "><a href="scopes-and-gc.html"><div class="inner"><span>Scopes And Garbage Collection</span></div></a></li><li class="depth-1 "><a href="slicing.html"><div class="inner"><span>Slicing And Slices</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>libpython-clj2</span></div></div></li><li class="depth-2 branch current"><a href="libpython-clj2.codegen.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>codegen</span></div></a></li><li class="depth-2"><a href="libpython-clj2.python.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>python</span></div></a></li><li class="depth-3"><a href="libpython-clj2.python.np-array.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>np-array</span></div></a></li><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree" style="top: -114px;"><span class="top" style="height: 123px;"></span><span class="bottom"></span></span><span>python</span></div></div></li><li class="depth-2"><a href="python.builtins.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>builtins</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="libpython-clj2.codegen.html#var-write-namespace.21"><div class="inner"><span>write-namespace!</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">libpython-clj2.codegen</h1><div class="doc"><div class="markdown"><p>Generate a namespace on disk for a python module or instances</p></div></div><div class="public anchor" id="var-write-namespace.21"><h3>write-namespace!</h3><div class="usage"><code>(write-namespace! py-mod-or-cls {:keys [output-fname output-dir ns-symbol ns-prefix symbol-name-remaps exclude], :or {output-dir "src", ns-prefix "python", exclude default-exclude}})</code><code>(write-namespace! py-mod-or-cls)</code></div><div class="doc"><div class="markdown"><p>Generate a clojure namespace file from a python module or class. If python hasn’t been initialized yet this will call the default python initialization. Accessing the generated namespace without initialization will cause an error.</p> | ||
<p>Once generated this namespace is safe to be used for AOT,</p> | ||
<p>Options:</p> | ||
<ul> | ||
<li><code>:output-fname</code> - override the autogenerated file path.</li> | ||
<li><code>:output-dir</code> - Defaults “src”. Set the output directory. The final filename, if <code>:output-fname</code> is not provided, is built up from <code>:ns-prefix and | ||
</code>py-mod-or-cls`.</li> | ||
<li><code>:ns-symbol</code> - The fully qualified namespace symbol. If not provided is built from <code>:ns-prefix</code> and <code>py-mod-or-cls</code>.</li> | ||
<li><code>:ns-prefix</code> - The prefix used for all python namespaces. Defaults to “python”.</li> | ||
<li><code>:symbol-name-remaps</code> - A list of remaps used to avoid name clashes with clojure.core or builtin java symbols.</li> | ||
<li><code>:exclude</code> - List of symbols used like <code>(:refer-clojure :exclude %s)</code>. You can see the default list as <code>codegen/default-exclude</code>.</li> | ||
</ul> | ||
<p>Example:</p> | ||
<pre><code class="clojure">user> (require '[libpython-clj2.codegen :as codegen]) | ||
nil | ||
user> (codegen/write-namespace! | ||
"builtins" {:symbol-name-remaps {"AssertionError" "PyAssertionError" | ||
"Exception" "PyException"}}) | ||
:ok | ||
user> (require '[python.builtins :as python]) | ||
nil | ||
user> (doc python/list) | ||
------------------------- | ||
python.builtins/list | ||
[[self & [args {:as kwargs}]]] | ||
Built-in mutable sequence. | ||
|
||
If no argument is given, the constructor creates a new empty list. | ||
The argument must be an iterable if specified. | ||
nil | ||
user> (doto (python/list) | ||
(.add 1) | ||
(.add 2)) | ||
[1, 2] | ||
</code></pre></div></div><div class="src-link"><a href="https://github.com/clj-python/libpython-clj/blob/master/src/libpython_clj2/codegen.clj#L85">view source</a></div></div></div></body></html> |
Oops, something went wrong.