{"id":15510,"date":"2016-12-28T12:15:36","date_gmt":"2016-12-28T10:15:36","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=15510"},"modified":"2016-12-23T14:24:15","modified_gmt":"2016-12-23T12:24:15","slug":"testing-code-examples-documentation","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/","title":{"rendered":"Testing Code Examples in Documentation"},"content":{"rendered":"<p>In my last post, I covered <a href=\"https:\/\/www.webcodegeeks.com\/web-development\/improve-documentation-automating-spelling-grammar-checks\/\">how to improve the written component of your documentation<\/a> with automated spell-checking and suggestions for better writing. In this post, I\u2019ll cover the code component of good documentation; trying an example and finding it doesn\u2019t work is a sure-fire way to annoy a reader.<\/p>\n<p>The techniques for testing code fall into two distinct camps, depending on what you\u2019re testing. Again, I will present one example in detail and then link to alternatives with similar functionality.<\/p>\n<h2>Testing API Examples with Dredd<\/h2>\n<p>Whether you generate your API documentation from the source code or write it externally, the more distinct nature of an (your) API makes it easier to test. Tooling options also frequently offer the auto-generation of examples as well as tests, automating even more mundane tasks for you.<\/p>\n<h3>Dredd<\/h3>\n<p>I have had the most experience with using <a href=\"https:\/\/github.com\/apiaryio\/dredd\">Dredd<\/a>. It works with API documentation outlined in the <a href=\"http:\/\/swagger.io\/\">swagger<\/a> and <a href=\"https:\/\/apiblueprint.org\/\">API blueprint<\/a> formats, so documentation is written externally to your API source code.<\/p>\n<p>I will use the <a href=\"https:\/\/developer.marvel.com\/\">Marvel API<\/a> as an example for this section. Instead of attempting to create an entire API definition of the API from scratch, I found an existing API Blueprint file floating on the internet and created a demo project around it. You can find the project on <a href=\"https:\/\/github.com\/ChrisChinchilla\/Code-Ship-API-Docs-test-examples\">GitHub<\/a>.<\/p>\n<p>I\u2019ll only cover the essentials of what\u2019s inside the projects. Otherwise this article would turn into a fully fledged API Blueprint and Dredd tutorial.<\/p>\n<p>The API definitions in the file I found are out of date, so running the tests will fail. I decided to leave this as is for a couple reasons. First, you\u2019ll still be able to appreciate the setup process for Dredd and its potential. Also it\u2019s unlikely that you want to test the Marvel API. Unless you work for Marvel, in which case, release an updated file &amp;#55357;&amp;#56861;.<\/p>\n<p>As Dredd integrates with Node and npm, you can use the default setup with a new Codeship project, selecting <em>node.js<\/em> as the language of the project.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-setup.png\"><img decoding=\"async\" class=\"aligncenter wp-image-15515\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-setup.png\" width=\"860\" height=\"420\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-setup.png 947w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-setup-300x147.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-setup-768x375.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The dependencies defined in <em>package.json<\/em> are:<\/p>\n<pre class=\"brush:php\">...\r\n\"dependencies\": {\r\n  \"dredd\": \"^2.2.5\",\r\n  \"md5\": \"^2.1.0\",\r\n  \"dotenv\": \"^2.0.0\"\r\n}\r\n...<\/pre>\n<p>With most needed for using the Marvel API, not Dredd.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-test.png\"><img decoding=\"async\" class=\"aligncenter wp-image-15516\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-test.png\" width=\"860\" height=\"383\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-test.png 969w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-test-300x134.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-test-768x342.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>And the test command defined in <em>package.json<\/em> is:<\/p>\n<pre class=\"brush:php\">...\r\n\"scripts\": {\r\n   \"test\": \"dredd\"\r\n }\r\n...<\/pre>\n<p>The final piece of the setup puzzle is the <em>dredd.yml<\/em> configuration file, which you can auto-generate with the <code>dredd init<\/code> command. The overridden settings are:<\/p>\n<pre class=\"brush:php\">hookfiles: .\/hooks.js\r\nlanguage: nodejs\r\nconfig: .\/dredd.yml\r\nblueprint: marvel.apib\r\nendpoint: 'https:\/\/gateway.marvel.com:443\/v1\/public\/'<\/pre>\n<p>You can find more here about <a href=\"http:\/\/dredd.readthedocs.io\/en\/latest\/usage-js\/#configuration-object-for-dredd-class\">Dredd configuration in their documentation<\/a>.<\/p>\n<p>You can find the API definitions in the <em>marvel.apib<\/em> file, which are a series of endpoints, with parameters passed to them and an expected response. The API Blueprint format is standard markdown with extras added for API modelling, which means it\u2019s well-suited for adding good explanatory text around the API definitions.<\/p>\n<p>All calls to the Marvel API need an <code>apikey<\/code> parameter appended, <a href=\"http:\/\/developer.marvel.com\/documentation\/getting_started\">constructed in a slightly complicated way<\/a>. You could add this as a parameter to every endpoint definition, but there\u2019s a much better way.<\/p>\n<p>Dredd\u2019s \u2018<a href=\"http:\/\/dredd.readthedocs.io\/en\/latest\/hooks\/\">hooks<\/a>\u2018 feature allows you to interrupt the processing flow and make amendments. The <em>hooks.js<\/em> file below interrupts every API call before it\u2019s sent to the API and adds the <code>apikey<\/code> that the Marvel API expects:<\/p>\n<pre class=\"brush:php\">'use strict';\r\n\r\nrequire('dotenv').config();\r\n\r\nvar hooks = require('hooks');\r\nvar md5 = require('md5');\r\n\r\nhooks.beforeEach(function (transaction) {\r\n  var publicKey = process.env.MARVEL_PUBLIC_KEY;\r\n  var privateKey = process.env.MARVEL_PRIVATE_KEY;\r\n  var ts = String(new Date().getTime());\r\n  var hash = md5(ts+privateKey+publicKey);\r\n\r\n  transaction.fullPath = transaction.fullPath + '?ts=' + ts + '\u2248ikey=' + publicKey + '&amp;hash=' + hash ;\r\n});<\/pre>\n<p>Now whenever you push to the repository, Codeship will run the tests you\u2019ve defined. As I mentioned, the build will currently fail, as the expected response doesn\u2019t match the actual response. If you want to experiment and learn further, then you can try updating the API Blueprint file to match the new response structure. Or spend that time making Dredd work with your own API.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-fail.png\"><img decoding=\"async\" class=\"aligncenter wp-image-15517\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-fail.png\" width=\"860\" height=\"654\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-fail.png 885w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-fail-300x228.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-fail-768x584.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<h3>Other options<\/h3>\n<p>If you want to use a SaaS to design\/host\/test your APIs, then a quick search will show that there are dozens of options. Here\u2019s a quick roundup of other open-source and free options; not all work that well within a CI context.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.getpostman.com\">Postman<\/a>: Better known as a desktop app, you can also <a href=\"https:\/\/www.getpostman.com\/docs\/writing_tests\">automate Postman<\/a>.<\/li>\n<li><a href=\"https:\/\/www.soapui.org\">Soap UI<\/a>: Primarily a desktop application, <a href=\"https:\/\/www.soapui.org\/test-automation\/running-functional-tests.html\">but possible to automate on certain platforms<\/a>.<\/li>\n<li>Roll your own: Testing an API is a series of HTTP calls with parameters and an expected response, so coding your own and connecting it to a CI is not too complicated.<\/li>\n<\/ul>\n<h2>Testing Code Examples<\/h2>\n<p>Aside from API documentation, I hope you also have a series of tutorials that helps users assemble the API components into something useful. These will frequently contain snippets of code that readers follow. How many times have you tried one that didn\u2019t work?<\/p>\n<p>Automatically testing these snippets is a fantastic idea, but it\u2019s unfortunately hard to do. This is due to the nature of a code snippet; it\u2019s an abstract extraction of an application, so how can you test it with no context?<\/p>\n<p>It can work with certain languages; SQL for example, which are discrete commands that a CI tool can run and test. Or small, simple code snippets that can work in isolation.<\/p>\n<p>I have had a couple of ideas suggested to me as a general solution to this problem, but I haven\u2019t implemented any yet. One is to extract each code snippet from a document, generate separate files for the code, and test those. Another is to make sure that each snippet can work in isolation from the rest of the application and is thus testable, but this leads to less understandable documentation.<\/p>\n<h3>Python developers rejoice with Sphinx<\/h3>\n<p>After that lengthy disclaimer (and food for thought), there is one concrete tool out there for Python developers in the form of <a href=\"http:\/\/www.sphinx-doc.org\/en\/1.5.1\/\">Sphinx<\/a>. Sphinx is a mature documentation project primarily aimed at Python developers, but usable (to varying degrees of functionality) by other developers. Generally the Python community has the best documentation tools; pity I don\u2019t work with more Python-based projects.<\/p>\n<p>The Sphinx project has great <a href=\"http:\/\/www.sphinx-doc.org\/en\/1.5.1\/tutorial.html\">installation and Getting Started guides<\/a>, so follow those first.<\/p>\n<p>Follow the <code>sphinx-quickstart<\/code> option. The installer will ask if you want to include the <code>doctest<\/code> extension (the magic extensions), so select <code>y<\/code>.<\/p>\n<p>Continuing the Getting Started guide will give you more information on reStructuredText and Sphinx. For this article, I will dive right into creating an example to test. <a href=\"https:\/\/github.com\/ChrisChinchilla\/Code-Ship-examples-Test\">You can find the final project on GitHub<\/a>.<\/p>\n<p>In the <em>index.rst<\/em> file, add the following:<\/p>\n<pre class=\"brush:php\">.. testsetup:: *\r\n\r\n  import os\r\n\r\nLook at this great example:\r\n\r\n.. doctest::\r\n\r\n  &gt;&gt;&gt; sum((2, 2))\r\n  4\r\n\r\nTest-Output example:\r\n\r\n.. testcode::\r\n\r\n  sum((2, 2))\r\n\r\nThis would output:\r\n\r\n.. testoutput::\r\n\r\n  4<\/pre>\n<p>There\u2019s some cool syntax here. First <code>testsetup<\/code> lets you add code needed for the example to work but that a reader won\u2019t actually see. The <code>doctest<\/code> shows the code example that the user will see and the expected result. The <code>testcode<\/code> and <code>testouput<\/code> pair are equivalent to the <code>doctest<\/code>, but separated. Pick whichever option you like the most.<\/p>\n<p>Now you can run:<\/p>\n<pre class=\"brush:php\">make doctest<\/pre>\n<p>This will use the auto-generated <em>Makefile<\/em> to run the <code>doctest<\/code> task, which should succeed with the following output:<\/p>\n<pre class=\"brush:php\">Document: index\r\n---------------\r\n1 items passed all tests:\r\n   1 tests in default\r\n1 tests in 1 items.\r\n1 passed and 0 failed.\r\nTest passed.\r\n\r\nDoctest summary\r\n===============\r\n    1 test\r\n    0 failures in tests\r\n    0 failures in setup code\r\n    0 failures in cleanup code\r\nbuild succeeded.\r\nTesting of doctests in the sources finished, look at the results in _build\/doctest\/output.txt.<\/pre>\n<p>To get this working with Codeship, create a new project and set it as a Python project. Leave the commands as default; the GitHub repository contains the <em>requirements.txt<\/em> file needed.<\/p>\n<p>Remove what\u2019s in the test pipeline section and add the <code>make doctest<\/code> command. Save the project and trigger a build.<\/p>\n<p>And voil\u00e0, as expected, you can be assured that your code examples are usable by readers.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-succeed.png\"><img decoding=\"async\" class=\"aligncenter wp-image-15518\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-succeed.png\" width=\"860\" height=\"543\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-succeed.png 881w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-succeed-300x189.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/tca-succeed-768x485.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<h2>Test All the Things<\/h2>\n<p>And that\u2019s it! In the next and final installment of this series of posts, I will look at automating screenshots. If you have comments and suggestions, please let me know below. I\u2019d especially like to know if you have solutions to the tooling gaps I identified throughout the article.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/blog.codeship.com\/testing-code-examples-in-documentation\/\">Testing Code Examples in Documentation<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a>\u00a0Chris Ward at the <a href=\"http:\/\/blog.codeship.com\/\">Codeship Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In this post, I\u2019ll cover the code component of good documentation; trying an example and finding it doesn\u2019t work is a sure-fire way to annoy a reader. The techniques for testing code &hellip;<\/p>\n","protected":false},"author":148,"featured_media":927,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-15510","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Testing Code Examples in Documentation - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Testing Code Examples in Documentation - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-28T10:15:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chris Ward\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chris Ward\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\"},\"author\":{\"name\":\"Chris Ward\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ec768d779e3ecb955c5f552f0f734757\"},\"headline\":\"Testing Code Examples in Documentation\",\"datePublished\":\"2016-12-28T10:15:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\"},\"wordCount\":1255,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"articleSection\":[\"Web Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\",\"name\":\"Testing Code Examples in Documentation - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"datePublished\":\"2016-12-28T10:15:36+00:00\",\"description\":\"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Dev\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Testing Code Examples in Documentation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ec768d779e3ecb955c5f552f0f734757\",\"name\":\"Chris Ward\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e715e4a95de958fcd3da75cde89b6459b80f977d665284e37751ecdcb2b1e4c4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e715e4a95de958fcd3da75cde89b6459b80f977d665284e37751ecdcb2b1e4c4?s=96&d=mm&r=g\",\"caption\":\"Chris Ward\"},\"description\":\"Chris Ward is a technical writer, speaker, and developer.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/chris-ward\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Testing Code Examples in Documentation - Web Code Geeks - 2026","description":"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/","og_locale":"en_US","og_type":"article","og_title":"Testing Code Examples in Documentation - Web Code Geeks - 2026","og_description":"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In","og_url":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-12-28T10:15:36+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","type":"image\/jpeg"}],"author":"Chris Ward","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Chris Ward","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/"},"author":{"name":"Chris Ward","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ec768d779e3ecb955c5f552f0f734757"},"headline":"Testing Code Examples in Documentation","datePublished":"2016-12-28T10:15:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/"},"wordCount":1255,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","articleSection":["Web Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/","url":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/","name":"Testing Code Examples in Documentation - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","datePublished":"2016-12-28T10:15:36+00:00","description":"In my last post, I covered how to improve the written component of your documentation with automated spell-checking and suggestions for better writing. In","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/web-development\/testing-code-examples-documentation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Dev","item":"https:\/\/www.webcodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"Testing Code Examples in Documentation"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ec768d779e3ecb955c5f552f0f734757","name":"Chris Ward","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e715e4a95de958fcd3da75cde89b6459b80f977d665284e37751ecdcb2b1e4c4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e715e4a95de958fcd3da75cde89b6459b80f977d665284e37751ecdcb2b1e4c4?s=96&d=mm&r=g","caption":"Chris Ward"},"description":"Chris Ward is a technical writer, speaker, and developer.","url":"https:\/\/www.webcodegeeks.com\/author\/chris-ward\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/148"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=15510"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15510\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/927"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=15510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=15510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=15510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}