aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorstewartamiles <stewartamiles@40f4469a-5155-0410-be90-2de3f0bae501>2009-07-23 16:37:13 +0000
committerstewartamiles <stewartamiles@40f4469a-5155-0410-be90-2de3f0bae501>2009-07-23 16:37:13 +0000
commit85f3cedf3f9b5cad3d69083d3b6ff4cb2049929b (patch)
tree7955c6af24c2e180ff743a284f920c4e7e1b8629 /doc
parent342ddac73d4849e9d5d5e117974354460238b1e8 (diff)
downloadcmocka-85f3cedf3f9b5cad3d69083d3b6ff4cb2049929b.tar.gz
cmocka-85f3cedf3f9b5cad3d69083d3b6ff4cb2049929b.tar.xz
cmocka-85f3cedf3f9b5cad3d69083d3b6ff4cb2049929b.zip
* Added bash (awk / sed) script to convert cmockery's html docs to a googlecode.com wiki.
* Modified index.html slightly to make the conversion from html to wiki easier. git-svn-id: http://cmockery.googlecode.com/svn/trunk@39 40f4469a-5155-0410-be90-2de3f0bae501
Diffstat (limited to 'doc')
-rw-r--r--doc/html2wiki.sh151
-rw-r--r--doc/index.html68
2 files changed, 179 insertions, 40 deletions
diff --git a/doc/html2wiki.sh b/doc/html2wiki.sh
new file mode 100644
index 0000000..a7892ce
--- /dev/null
+++ b/doc/html2wiki.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+#
+# Translate really simple html to googlecode.com wiki.
+#
+# Usage: cat input.html | html2wiki.sh > outputwiki.txt
+#
+# Most of this script is simple sed substitutions with an awk script to handle
+# hierarchical lists.
+
+# Awk program to escape all instances of * outside of <listing></listing>
+awk '
+BEGIN { in_listing = 0; }
+/<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 1; }
+/<\/[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 0; }
+/.*/ {
+ if (in_listing) {
+ print $0;
+ } else {
+ print gensub("*", "`*`", "g", $0)
+ }
+}' | \
+# Awk program to convert hierachical unordered and ordered lists into
+# googlecode wiki list markup. This is limited to converting very simple
+# html lists in the form:
+#
+# <ul>
+# <li>item 1</li>
+# ...
+# <li>item N</li>
+# </ul>
+#
+# This script also removes leading spaces from all lines outside of <listing>
+# sections.
+awk '
+BEGIN {
+ list_type_none = 0;
+ list_type_ordered = 1;
+ list_type_unordered = 2;
+ # Number of nested lists.
+ list_depth = 0;
+ # Number of items in the list.
+ list_items[list_depth] = 0;
+ # Type of list.
+ list_type[list_depth] = list_type_none;
+ # Do nott strip whitespace from listing sections.
+ in_listing = 0;
+}
+
+# Generate a string of indent spaces.
+function list_indent(indent) {
+ format = sprintf("%%%ds", indent);
+ return sprintf(format, "");
+}
+
+/<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 1; }
+/<\/[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 0; }
+
+# Process all lines non-blank lines.
+/^.*$/ {
+ # Remove leading white space.
+ if (!in_listing) {
+ output_string = gensub(/^ */, "", 1, $0);
+ } else {
+ output_string = $0;
+ }
+ search_string = output_string
+
+ # Replace list tags with googlecode wiki markup.
+ while (match(search_string, /<[^>]*>/, matches)) {
+ tag = matches[0];
+ search_string = substr(search_string,
+ matches[0, "start"] + matches[0, "length"]);
+ if (match(tag, /^<[Uu][Ll]>$/)) {
+ list_depth++;
+ list_type[list_depth] = list_type_unordered;
+ list_items[list_depth] = 0;
+ output_string = gensub(tag, "", 1, output_string);
+ } else if (match(tag, /^[Oo][Ll]>$/)) {
+ list_depth++;
+ list_type[list_depth] = list_type_ordered;
+ list_items[list_depth] = 0;
+ output_string = gensub(tag, "", 1, output_string);
+ } else if (match(tag, /^<\/[Ll][Ii]>$/)) {
+ output_string = gensub(tag, "", 1, output_string);
+ } else if (list_depth) {
+ if (match(tag, /^<[Ll][Ii]>$/)) {
+ if (list_type[list_depth] == list_type_unordered) {
+ output_string = gensub(tag, list_indent(list_depth) "* ", 1,
+ output_string);
+ } else if (list_type[list_depth] == list_type_ordered) {
+ output_string = gensub(tag, list_indent(list_depth) "# ", 1,
+ output_string);
+ }
+ } else if (match(tag, /^<\/[Uu][Ll]>$/) ||
+ match(tag, /^<\/[Ou][Ll]>$/)) {
+ output_string = gensub(tag, "", 1, output_string);
+ list_depth --;
+ }
+ }
+ }
+ # If a list is being parsed then filter blank lines.
+ if (list_depth == 0 || length(output_string)) {
+ print output_string
+ }
+}
+' | \
+# This sed program translates really simple html into wiki suitable for
+# googlecode.com.
+#
+# Supported tags:
+# <p>
+# <br>
+# <h1>
+# <h2>
+# <h3>
+# <h4>
+# <h5>
+# <b>
+# <i>
+# <a href="#.*">.*</a>
+# <a href=".*">.*</a>
+# <a name=".*'>.*</a>
+#
+# Supported entities:
+# &gt;
+# &lt;
+#
+# Limitations:
+# * Anchors must be on a single line and must contain one of either the name or
+# href attributes.
+# * All external links are relative to
+# http://cmockery.googlecode.com/svn/trunk/doc/
+sed -r '
+s@<[Pp]>@\n@g;
+s@<[[Bb][Rr]]>@\n@g;
+s@</?[Hh]1>@=@g;
+s@</?[Hh]2>@==@g;
+s@</?[Hh]3>@===@g;
+s@</?[Hh]4>@====@g;
+s@</?[Hh]5>@====@g;
+s@</?[Bb]>@*@g;
+s@</?[Ii]>@_@g;
+s@<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>@{{{@g;
+s@</[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>@}}}@g;
+s@<[Aa].*?href="#(.*)?">(.*)?</[Aa]>@[#\1 \2]@g;
+s@<[Aa].*?href="(.*)?">(.*)?</[Aa]>@[http://cmockery.googlecode.com/svn/trunk/doc/\1 \2]@g;
+s@<[Aa].*?name="(.*)?">@@g;
+s@</[Aa]>@@g;
+s@<.*?>@@g;
+s@&lt;@<@g;
+s@&gt;@>@g;'
diff --git a/doc/index.html b/doc/index.html
index a4b897f..384e732 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -74,9 +74,8 @@ is complete <b>run_tests()</b> performs various checks to determine whether
the test succeeded.</p>
<h4>Using run_tests()</h4>
-<listing>
<a href="../src/example/run_tests.c">run_tests.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
@@ -117,10 +116,8 @@ failure...
<li><a href="#TestState">Mismatched setup and tear down functions</a></li>
<li><a href="#MockFunctionsReturnValues">Missing mock return values</a></li>
<li><a href="#MockFunctionsReturnValues">Unused mock return values</a></li>
- <li><a href="#MockFunctionsCheckingParameters">Missing expected parameter
- values</a></li>
- <li><a href="#MockFunctionsCheckingParameters">Unused expected parameter
- values</a></li>
+ <li><a href="#MockFunctionsCheckingParameters">Missing expected parameter values</a></li>
+ <li><a href="#MockFunctionsCheckingParameters">Unused expected parameter values</a></li>
</ul>
</p>
@@ -135,9 +132,8 @@ calls to <b>mock_assert()</b> occur during the function called via
<b>expect_assert_failure()</b> a test failure is signalled.</p>
<h4>Using mock_assert()</h4>
-<listing>
<a href="../src/example/assert_module.c">assert_module.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;assert.h&gt;
// If unit testing is enabled override assert with mock_assert().
@@ -159,9 +155,9 @@ void decrement_value(int * const value) {
*value --;
}
}
-
+</listing>
<a href="../src/example/assert_module_test.c">assert_module_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
@@ -210,9 +206,8 @@ caused the assertion failure which increases data visibility aiding
debugging of failing test cases.</p>
<h4>Using assert_{type}_equal() macros</h4>
-<listing>
<a href="../src/example/assert_macro.c">assert_macro.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;string.h&gt;
static const char* status_code_strings[] = {
@@ -235,9 +230,9 @@ unsigned int string_to_status_code(const char* const status_code_string) {
}
return ~0U;
}
-
+</listing>
<a href="../src/example/assert_macro_test.c">assert_macro_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
@@ -286,9 +281,8 @@ which means memory corruption from a single test case could potentially cause
the test application to exit prematurely.</p>
<h4>Using Cmockery's Allocators</h4>
-<listing>
<a href="../src/example/allocate_module.c">allocate_module.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;malloc.h&gt;
#if UNIT_TESTING
@@ -318,10 +312,9 @@ void buffer_underflow() {
memory[-1] = '!';
free(memory);
}
-
-
+</listing>
<a href="../src/example/allocate_module_test.c">allocate_module_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
@@ -381,9 +374,8 @@ return value. In addition this allows the specification of return values for
multiple calls to a mock function.</p>
<h4>Using will_return()</h4>
-<listing>
<a name="../src/example/database.h" href="database.h">database.h</a>
--------------------------------------------------------------------------------
+<listing>
typedef struct DatabaseConnection DatabaseConnection;
/* Function that takes an SQL query string and sets results to an array of
@@ -405,13 +397,12 @@ struct DatabaseConnection {
// Connect to a database.
DatabaseConnection* connect_to_database(const char * const url,
const unsigned int port);
-
-
+</listing>
<a href="../src/example/customer_database.c">customer_database.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stddef.h&gt;
#include &lt;stdio.h&gt;
-#include <a href="#database.h">&lt;database.h&gt;</a>
+#include &lt;database.h&gt;
#ifdef _WIN32
#define snprintf _snprintf
#endif // _WIN32
@@ -438,15 +429,14 @@ unsigned int get_customer_id_by_name(
}
return (unsigned int)results[0];
}
-
-
+</listing>
<a href="../src/example/customer_database_test.c">customer_database_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
#include &lt;cmockery.h&gt;
-#include <a href="#database.h">&lt;database.h&gt;</a>
+#include &lt;database.h&gt;
extern DatabaseConnection* connect_to_customer_database();
@@ -515,23 +505,22 @@ test failure is signalled. In addition if check_expected() is called and
no more parameter values are queued a test failure occurs.</p>
<h4>Using expect_*()</h4>
-<listing>
<a href="../src/example/product_database.c">product_database.c</a>
--------------------------------------------------------------------------------
-#include <a href="#database.h">&lt;database.h&gt;</a>
+<listing>
+#include &lt;database.h&gt;
// Connect to the database containing customer information.
DatabaseConnection* connect_to_product_database() {
return connect_to_database("products.abcd.org", 322);
}
-
+</listing>
<a href="../src/example/product_database_test.c">product_database_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
#include &lt;cmockery.h&gt;
-#include <a href="#database.h">&lt;database.h&gt;</a>
+#include &lt;database.h&gt;
extern DatabaseConnection* connect_to_product_database();
@@ -591,9 +580,8 @@ specified by the <b>unit_test_teardown()</b> or
executed for a test case even when it fails.</p>
<h4>Using unit_test_setup_teardown()</h4>
-<listing>
<a href="../src/example/key_value.c">key_value.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stddef.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
@@ -633,9 +621,9 @@ void sort_items_by_key() {
qsort(key_values, number_of_key_values, sizeof(*key_values),
key_value_compare_keys);
}
-
+</listing>
<a href="../src/example/key_value_test.c">key_value_test.c</a>
--------------------------------------------------------------------------------
+<listing>
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;setjmp.h&gt;
@@ -714,5 +702,5 @@ are provided as an example of Cmockery's features discussed in this document.
<hr>
<address></address>
-<!-- hhmts start --> Last modified: Mon Jul 6 12:21:30 PDT 2009 <!-- hhmts end -->
+<!-- hhmts start --> Last modified: Mon Jul 20 15:57:27 PDT 2009 <!-- hhmts end -->
</body> </html>