Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/sm/sm_apidoc

  • Loading branch information...
commit 52e5bf1c6d1250120d838841dffb3182d621fd84 2 parents 5b24b0e + b4c4467
Ines Sombra authored
Showing with 41 additions and 12 deletions.
  1. +10 −5 README.md
  2. +15 −0 bin/array/first
  3. +0 −3  bin/array/is/empty
  4. +16 −4 bin/array/last
View
15 README.md
@@ -6,18 +6,20 @@ usage for all Module APIs exposed to Extension Developers.
Each extension within the set contains examples for the commands provided by the
corresponding API.
-In order to install the set to be able to use the examples,
+In order to be able to use these examples, install this repository as an SM
+Framework extension:
sm ext install apidoc https://github.com/sm/sm_apidoc
-Once you have installed the set you can then proceed to show examples for a
-specific API command run that API command prefixed with sm.
+Once you have installed the apidoc extension you can then proceed to run
+examples for a specific API command run that API command prefixed with sm.
-Let's say that we want to know details about the 'array each' API command call,
+As an example, let's say that we want to know details about the 'array each'
+API command call,
sm apidoc array each
-Will display the examples for the array each api.
+This will display the examples / tutorial for the array each api.
To see all api commands documented for 'array' api,
@@ -27,3 +29,6 @@ For descriptions,
sm man apidoc array
+Note that the apidocs are a work in progress and not yet complete.
+Currently {array,files,paths} are the most complete apidocs.
+
View
15 bin/array/first
@@ -19,3 +19,18 @@ array print my_array
# one
array first "my_array"
+
+# We can printout the index of the first element:
+# 1
+array first "my_array" index
+
+# Let's declare a string variable
+typeset my_variable
+
+# We can specify to store the first element in a given variable name:
+array first "my_array" as "my_variable"
+
+# This should output:
+# one
+log $my_variable
+
View
3  bin/array/is/empty
@@ -7,9 +7,6 @@ set -v # Turn on verbose logging, so that the following will present a tutorial.
# First we declare the my_array variable that we will use, as an array ('-a')
typeset -a my_array
-# Now we assign five elements into our array.
-my_array=(one two three four five)
-
# We can test if the array is empty, which it should be at this point.
# Thus the output here should be:
# The array is empty.
View
20 bin/array/last
@@ -4,7 +4,7 @@ set -v # Turn on verbose logging, so that the following will present a tutorial.
# array(s) module api is loaded with the line 'api/array' in shell/includes.
-# First we declare the my_array variable that we will use, as an array ('-a')
+# last we declare the my_array variable that we will use, as an array ('-a')
typeset -a my_array
# Now we assign five elements into our array.
@@ -16,8 +16,20 @@ my_array=(one two three four five)
array print my_array
-# We can print out the last element of the array to standard out:
-# one
-array last my_array
+# This should print out the last element to standard output:
+# five
+array last "my_array"
+# We can printout the index of the last element:
+# 5
+array last "my_array" index
+# Let's declare a string variable
+typeset my_variable
+
+# We can specify to store the last element in a given variable name:
+array last "my_array" as "my_variable"
+
+# This should output:
+# five
+log $my_variable
Please sign in to comment.
Something went wrong with that request. Please try again.