Created
January 30, 2019 08:25
-
-
Save rbarzic/59232b080a022417cac434c31152da94 to your computer and use it in GitHub Desktop.
Example of org-mode/tangle
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
#+TITLE: Example of using org/babel to do litterate programming | |
#+AUTHOR: Ronan BARZIC | |
#+EMAIL: ronan.barzic@onio.com | |
To "tangle" it : C-c C-v t | |
#+BEGIN_SRC python :noweb yes :tangle HelloWorld.py :exports none | |
"""This is a hello world example document""" | |
# imports | |
import sys | |
<<helloworld-main-imports>> | |
# constants | |
# exception classes | |
# interface functions | |
# classes | |
<<HelloWorld-defn>> | |
# internal functions & classes | |
<<helloworld-main>> | |
if __name__ == '__main__': | |
status = main() | |
sys.exit(status) | |
#+END_SRC | |
#+NAME: HelloWorld-defn | |
#+BEGIN_SRC python | |
class HelloWorld(object): | |
def __init__(self, who): | |
self.who = who | |
def say_hello(self): | |
print "Hello %s" % self.who | |
#+END_SRC | |
#+NAME: helloworld-main-imports | |
#+BEGIN_SRC python | |
from argparse import ArgumentParser | |
#+END_SRC | |
#+NAME: helloworld-main | |
#+BEGIN_SRC python | |
def main(): | |
parser = ArgumentParser(description="Say hi") | |
parser.add_argument("-w", "--who", | |
type=str, | |
default="world", | |
help="Who to say hello to") | |
args = parser.parse_args() | |
who = args.who | |
greeter = HelloWorld(who) | |
greeter.say_hello() | |
return 0 | |
#+END_SRC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is another working example I use for scan pins. All inputs driven to '0 and all outputs open.
.(.scan.) (@"(if (equal vl-dir \"input\") \"'0\" \"\")"),
Here are some examples of using vl-dir. Based on dir the prefix name changes.
.(a.*) (@"(if (equal vl-dir \"input\") \"snoc_ddr_ss_ctgt_\1\" \"ddr_snoc_ss_ctgt_\1\")"),