{"id":6687,"date":"2015-01-22T16:37:01","date_gmt":"2015-01-22T16:37:01","guid":{"rendered":"http:\/\/livecode.com\/?p=6687"},"modified":"2016-01-15T11:14:59","modified_gmt":"2016-01-15T11:14:59","slug":"documentation-documentation-documentation","status":"publish","type":"post","link":"https:\/\/legacy.livecode.com\/documentation-documentation-documentation\/","title":{"rendered":"Documentation, Documentation, Documentation"},"content":{"rendered":"<p>Rejected ideas for this blogpost:<br \/>\na) A meditation on the validity or otherwise of an oft-repeated quote attributed to Dick Brandon on the utility of documentation, whilst delicately avoiding the object of the quote&#8217;s comparison.<br \/>\nb) A rehash of <a href=\"http:\/\/www.theguardian.com\/politics\/2001\/may\/23\/labour.tonyblair\">Tony Blair&#8217;s 2001 speech on education<\/a>, with the word education replaced everywhere by the word documentation, Labour with LiveCode, etc etc, you see where I&#8217;m going with that.<br \/>\nc) An entire blog post written in the style of the documentation format, with some kind of tortured wordplay involving the words &#8220;meta&#8221; and &#8220;documentation&#8221; as the title.<\/p>\n<p><!--more--><\/p>\n<p>Rejected ideas for this blogpost:<br \/>\na) A meditation on the validity or otherwise of an oft-repeated quote attributed to Dick Brandon on the utility of documentation, whilst delicately avoiding the object of the quote&#8217;s comparison.<br \/>\nb) A rehash of <a href=\"http:\/\/www.theguardian.com\/politics\/2001\/may\/23\/labour.tonyblair\">Tony Blair&#8217;s 2001 speech on education<\/a>, with the word education replaced everywhere by the word documentation, Labour with LiveCode, etc etc, you see where I&#8217;m going with that.<br \/>\nc) An entire blog post written in the style of the documentation format, with some kind of tortured wordplay involving the words &#8220;meta&#8221; and &#8220;documentation&#8221; as the title.<\/p>\n<p>Hopefully I made a good decision to reject the above, although as you can see, remnants of those ideas have wormed their way in to this post regardless.<\/p>\n<p>It&#8217;s great to hear about various community efforts being organised to improve LiveCode&#8217;s User Guide, and translate it into various languages. Here at LiveCode we are continuing to try and find ways to empower our users both in terms of what it&#8217;s possible to do with LiveCode, and also ways to contribute to it. <a href=\"http:\/\/livecode.com\/blog\/2014\/11\/18\/markingdown-the-user-guide\/\">Elanor has already written about the user guide in this respect<\/a>;, and tt would be great if something similar could be done to make it easier to contribute the LiveCode Dictionary.<\/p>\n<p>Currently the dictionary files are in XML, which means they are rather opaquely swathed in tags. Some of these tags are meant to be rendered directly as HTML, while others are merely structural markings. Indeed, some of the older dictionary files contain extremely convoluted passages such as the following:<\/p>\n<pre style=\"word-wrap: break-word;\">&lt;description&gt;Use the &lt;b&gt;accept&lt;\/b&gt; &lt;glossary tag=\"command\"&gt;command&lt;\/glossary&gt; when running a &lt;glossary tag=\"server\"&gt;server&lt;\/glossary&gt;, to accept &lt;glossary tag=\"TCP\"&gt;TCP&lt;\/glossary&gt; connections or &lt;glossary tag=\"UDP\"&gt;UDP&lt;\/glossary&gt; &lt;glossary tag=\"datagram\"&gt;datagrams&lt;\/glossary&gt; from other systems (or other &lt;glossary tag=\"process\"&gt;processes&lt;\/glossary&gt; on the same system).&lt;p&gt;Use the datagram option if you want to accept UDP datagrams.&lt;\/p&gt;&lt;p&gt;&lt;\/p&gt;&lt;p&gt;&lt;b&gt;Parameters:&lt;\/b&gt;&lt;\/p&gt;&lt;p&gt;The &lt;i&gt;portNumber&lt;\/i&gt; is the &lt;glossary tag=\"TCP\"&gt;TCP&lt;\/glossary&gt; &lt;glossary tag=\"port\"&gt;port&lt;\/glossary&gt; number on which to accept connections.&lt;\/p&gt;&lt;p&gt;The &lt;i&gt;callbackMessage&lt;\/i&gt; is the name of a &lt;keyword tag=\"message box\"&gt;message&lt;\/keyword&gt; to be sent when a connection is made or a &lt;glossary tag=\"datagram\"&gt;datagram&lt;\/glossary&gt; is received.&lt;\/p&gt;&lt;p&gt;&lt;\/p&gt;&lt;p&gt;&lt;b&gt;Comments:&lt;\/b&gt;&lt;\/p&gt;&lt;p&gt;When a connection is made or a datagram is received, the &lt;b&gt;accept&lt;\/b&gt; &lt;glossary tag=\"command\"&gt;command&lt;\/glossary&gt; creates a new &lt;glossary tag=\"socket\"&gt;socket&lt;\/glossary&gt; that can be used to communicate with the other system (or &lt;glossary tag=\"process\"&gt;process&lt;\/glossary&gt;). When using the &lt;command tag=\"close socket\"&gt;close socket&lt;\/command&gt;, &lt;command tag=\"read from socket\"&gt;read from socket&lt;\/command&gt;, or &lt;command tag=\"write to socket\"&gt;write to socket&lt;\/command&gt; &lt;glossary tag=\"command\"&gt;commands&lt;\/glossary&gt;, you can refer to this &lt;glossary tag=\"socket\"&gt;socket&lt;\/glossary&gt; with a socket identifier that looks like this:&lt;\/p&gt;&lt;p&gt;&lt;i&gt;host&lt;\/i&gt;:&lt;i&gt;port&lt;\/i&gt;[|&lt;i&gt;connectionID&lt;\/i&gt;]&lt;\/p&gt;&lt;p&gt;where the &lt;i&gt;connectionID&lt;\/i&gt; is a number assigned by the &lt;b&gt;accept&lt;\/b&gt; &lt;glossary tag=\"command\"&gt;command&lt;\/glossary&gt;. (You only need to specify the connection number if there is more than one &lt;glossary tag=\"socket\"&gt;socket&lt;\/glossary&gt; connected to a particular &lt;glossary tag=\"port\"&gt;port&lt;\/glossary&gt; and &lt;glossary tag=\"disabled\"&gt;host&lt;\/glossary&gt;.)&lt;\/p&gt;&lt;p&gt;&lt;\/p&gt;&lt;p&gt;The &lt;i&gt;callbackMessage&lt;\/i&gt; is sent to the &lt;glossary tag=\"object\"&gt;object&lt;\/glossary&gt; whose &lt;property tag=\"script\"&gt;script&lt;\/property&gt; contains the &lt;b&gt;accept&lt;\/b&gt; &lt;glossary tag=\"command\"&gt;command&lt;\/glossary&gt;. Either one or two &lt;glossary tag=\"parameter\"&gt;parameters&lt;\/glossary&gt; are sent with this &lt;keyword tag=\"message box\"&gt;message&lt;\/keyword&gt;. The first &lt;glossary tag=\"parameter\"&gt;parameter&lt;\/glossary&gt; is the &lt;glossary tag=\"IP address\"&gt;IP address&lt;\/glossary&gt; of the system or &lt;glossary tag=\"process\"&gt;process&lt;\/glossary&gt; making the connection. If a &lt;glossary tag=\"datagram\"&gt;datagram&lt;\/glossary&gt; is being accepted, the second &lt;glossary tag=\"parameter\"&gt;parameter&lt;\/glossary&gt; is the contents of the &lt;glossary tag=\"datagram\"&gt;datagram&lt;\/glossary&gt;.&lt;\/p&gt;&lt;p&gt;&lt;\/p&gt;&lt;p&gt;For technical information about sockets, see RFC 147 at &lt;&lt;u&gt;http:\/\/www.ietf.org\/rfc\/rfc147.txt&lt;\/u&gt;&gt;.&lt;\/p&gt;&lt;p&gt;For technical information about UDP datagrams, see RFC 768 at &lt;&lt;u&gt;http:\/\/www.ietf.org\/rfc\/rfc0768.txt&lt;\/u&gt;&gt;.&lt;\/p&gt;&lt;p&gt;For technical information about the numbers used to designate standard ports, see the list of port numbers at &lt;&lt;u&gt;http:\/\/www.iana.org\/assignments\/port-numbers&lt;\/u&gt;&gt;&lt;i&gt;,&lt;\/i&gt; in particular the section entitled \"Well Known Port Numbers\".&lt;\/p&gt;&lt;\/description&gt;\r\n<\/pre>\n<p>&#8230;which can&#8217;t really be easily understood without, for example, displaying in a browser, or a field using the htmltext property. All of which makes it rather difficult to read and edit, and somewhat fragile too. So I spent some time recently thinking about how we could make dictionary files that are readable, extensible, and easy to adjust. Here is an example of the proposed format, again for the accept command:<\/p>\n<pre style=\"word-wrap: break-word;\">Name: accept\r\n\r\nType: command\r\n\r\nSyntax: accept [datagram] connections on port &lt;number&gt; with message &lt;callbackMessage&gt; \r\n\r\nSummary: Accepts an internet connection and creates a &lt;socket&gt; for that connection.\r\n\r\nIntroduced: 1.0\r\n\r\nOS: mac,windows,linux\r\n\r\nPlatforms: desktop,server,web\r\n\r\nSecurity: network\r\n\r\nExample:\r\naccept connections on port 80 with message \"connectionMade\"\r\n\r\nExample:\r\naccept datagram connections on port 80 with message \"connectionMade\"\r\n\r\nExample:\r\non mouseUp\r\n   accept connections on port 80 with message \"connectionMade\"\r\nend mouseUp\r\n\r\non connectionMade pIPAddress\r\n   put \"Connection made:\" &amp;&amp; pIPAddress\r\nend connectionMade\r\n\r\nParameters:\r\nnumber: \r\ncallbackMessage: The name of a message to be sent when a connection is made or a datagram is received.\r\nportNumber: The TCP port number on which to accept connections.\r\n\r\nDescription:\r\nUse the &lt;accept&gt; &lt;command&gt; when running a &lt;server&gt;, to accept &lt;TCP&gt; connections or &lt;UDP&gt; &lt;datagram|datagrams&gt; from other systems (or other &lt;process|processes&gt; on the same system).\r\nUse the datagram option if you want to accept UDP datagrams.\r\n\r\nWhen a connection is made or a datagram is received, the &lt;accept&gt; &lt;command&gt; creates a new &lt;socket&gt; that can be used to communicate with the other system (or &lt;process&gt;). When using the &lt;close socket&gt;, &lt;read from socket&gt;, or &lt;write to socket&gt; &lt;command|commands&gt;, you can refer to this &lt;socket&gt; with a socket identifier that looks like this:\r\nhost:port[|connectionID]\r\nwhere the connectionID is a number assigned by the &lt;accept&gt; &lt;command&gt;. (You only need to specify the connection number if there is more than one &lt;socket&gt; connected to a particular &lt;port&gt; and &lt;host&gt;.)\r\n\r\nThe &lt;callbackMessage&gt; is sent to the &lt;object&gt; whose &lt;script&gt; contains the &lt;accept&gt; &lt;command&gt;. Either one or two &lt;parameter|parameters&gt; are sent with this &lt;message&gt;. The first &lt;parameter&gt; is the &lt;IP address&gt; of the system or &lt;process&gt; making the connection. If a &lt;datagram&gt; is being accepted, the second &lt;parameter&gt; is the contents of the &lt;datagram&gt;.\r\n\r\nFor technical information about sockets, see RFC 147 at http:\/\/www.ietf.org\/rfc\/rfc147.txt.\r\nFor technical information about UDP datagrams, see RFC 768 at http:\/\/www.ietf.org\/rfc\/rfc0768.txt.\r\nFor technical information about the numbers used to designate standard ports, see the list of port numbers at http:\/\/www.iana.org\/assignments\/port-numbers, in particular the section entitled \"Well Known Port Numbers\".\r\n\r\nReferences: HTTPProxy (property), script (property), read from socket (command), write to socket (command), close socket (command), open socket (command), openSockets (function), hostAddressToName (function), hostName (function), hostAddress (function), peerAddress (function), hostNameToAddress (function), datagram (glossary), IP address (glossary), TCP (glossary), port (glossary), command (glossary), socket (glossary), UDP (glossary), host (glossary), server (glossary), message (glossary), parameter (glossary), process (glossary), object (object)\r\n\r\nTags: networking\r\n<\/pre>\n<p>There are really only two syntactic features of this docs format. The first is element specification, which is just done using a colon, e.g. Name: or Type:. The second is a general linking markup &#8211; enclosing text in &lt; and &gt;. Hopefully you&#8217;ll agree that the latter is much more legible, and editable to boot. Moreover, it points up an inconsistency in the original file, namely that there is a variable called &#8216;number&#8217; specified by the syntax, but the associated parameter being described is &#8216;portNumber&#8217;. Converting the xml files into this new format has uncovered all of these inconsistencies.<\/p>\n<p>The idea is that when we are building a new version of LiveCode, these docs files are parsed into an array which can be displayed by the dictionary in a CEF Browser object:<\/p>\n<p><a href=\"http:\/\/livecode.com\/wp-content\/uploads\/2015\/01\/AcceptEntry-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-6691\" src=\"http:\/\/livecode.com\/wp-content\/uploads\/2015\/01\/AcceptEntry-1-248x300.png\" alt=\"AcceptEntry (1)\" width=\"248\" height=\"300\" \/><\/a><\/p>\n<p>I created a LiveCode highlight.js build, so that we could display LiveCode script in the colours familiar to you from the script editor. You can see the result of that in the code snippets in the above image.<\/p>\n<p>You will also be able to document LiveCode script using exactly the same syntax, and autogenerate an API for it, if for example you are writing a library for distribution. The idea would be that you could add tabs in your dictionary viewer for each of the stacks that is currently being used as a library, as a handy reference tool.<\/p>\n<p>Much of this is in the early stages at the moment, so feedback is very welcome. If this or something like this does become the format of the dictionary files, we&#8217;ll immediately be seeking community help to improve our documentation. One of the primary objectives from my point of view would be to improve the examples. There are many examples in the dictionary which refer to not-necessarily-existant objects, or which rely on variables initialised outside of the example. It would be good if, as far as possible, the examples were self contained, and runnable; then they would hopefully be much more useful. I&#8217;d also like every parameter of the syntax to have as full a description as possible.<\/p>\n<p>Another important step we are taking is to include a table in every object&#8217;s dictionary entry, containing all of the messages and properties associated with that object. Here, for example is a snippet of how the image object&#8217;s new entry would look:<\/p>\n<p><a href=\"http:\/\/livecode.com\/wp-content\/uploads\/2015\/01\/ImageEntry.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-6694\" src=\"http:\/\/livecode.com\/wp-content\/uploads\/2015\/01\/ImageEntry-230x300.png\" alt=\"ImageEntry\" width=\"230\" height=\"300\" \/><\/a><\/p>\n<p>Let me know your thoughts in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rejected ideas for this blogpost: a) A meditation on the validity or otherwise of an oft-repeated quote attributed to Dick Brandon on the utility of documentation, whilst delicately avoiding the object of the quote&#8217;s comparison. b) A rehash of Tony Blair&#8217;s 2001 speech on education, with the word education replaced everywhere by the word documentation,<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"footnotes":""},"categories":[45],"tags":[176,177],"class_list":["post-6687","post","type-post","status-publish","format-standard","hentry","category-blog","tag-documentation","tag-tech"],"acf":[],"_links":{"self":[{"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/posts\/6687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/comments?post=6687"}],"version-history":[{"count":3,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/posts\/6687\/revisions"}],"predecessor-version":[{"id":16396,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/posts\/6687\/revisions\/16396"}],"wp:attachment":[{"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/media?parent=6687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/categories?post=6687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/legacy.livecode.com\/wp-json\/wp\/v2\/tags?post=6687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}