forked from clj-python/libpython-clj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibpython-clj2.codegen.html
48 lines (46 loc) · 6.52 KB
/
libpython-clj2.codegen.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>libpython-clj2.codegen documentation</title><script async="true" src="https://www.googletagmanager.com/gtag/js?id=G-LN7PG6FJ2D"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-LN7PG6FJ2D');</script><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.024</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>LibPython-CLJ Usage</span></div></a></li><li class="depth-1 "><a href="embedded.html"><div class="inner"><span>Embedding Clojure In Python</span></div></a></li><li class="depth-1 "><a href="environments.html"><div class="inner"><span>Python Environments</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 branch"><a href="libpython-clj2.embedded.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>embedded</span></div></a></li><li class="depth-2 branch"><a href="libpython-clj2.java-api.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>java-api</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 branch"><a href="libpython-clj2.python.class.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>class</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-2"><a href="libpython-clj2.require.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>require</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="language-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#L101">view source</a></div></div></div></body></html>