Browse Source

Added documentation for the import statement.

Also, removed that task from the TODO list
Steven Hall 8 years ago
parent
commit
54696eede6
2 changed files with 21 additions and 1 deletions
  1. 0 1
      TODO.md
  2. 21 0
      docs/syntax.html

+ 0 - 1
TODO.md

@@ -7,6 +7,5 @@
 * Improve parser error handling
 
 **DOCUMENTATION AND EXAMPLES**
-* Add documentation about import statement
 * Add examples with projects about API usage (C <-> Gravity)
 * Add the objc bridge with documentation

+ 21 - 0
docs/syntax.html

@@ -122,6 +122,27 @@
 		multi-line
 		comment
 	*/</code></pre>
+
+			<!-- IMPORTS -->
+			<h4 class="section-h4">Import</h4>
+			<p><b>NOTE:</b> currently, the path to the imported file is relative to
+			the location that the gravity executable was run.</p>
+			<p>Gravity supports importing code from other gravity files using the
+			import statement:</p>
+			<pre><code class="swift">
+	// adder.gravity
+	func add(x, y) {
+		return x+y;
+	}
+			</code></pre>
+			<pre><code class="swift">
+	// main.gravity
+	import "adder.gravity"
+
+	func main() {
+		System.print("5+4=" + add(5,4));
+	}
+			</code></pre>
 			
 			<!-- RESERVED KEYWORDS -->
 			<h4 class="section-h4">Reserved Keywords</h4>