Is the documentation online somewhere?

If not, could we put it somewhere?

If there isn’t an obvious other place, it could go on the wiki. I realise that the current format is probably not suitable for just cut-and-pasting, but it’s probably nothing a decent perl script couldn’t fix …

http://twolivesleft.com/Codea/Reference - please note it only works in Webkit browsers. We can make the raw JSON source available if anyone wants to feed that into a different front-end.

yes please - I use chrome habitually. Meant to mention this long ago, slipped my mind.

Is there some reason it shouldn’t be viewable with any browser???

Chrome is a Webkit browser, it should work in Chrome.

The reason it’s not viewable in any browser is because it uses the Sencha Touch JS framework, which is designed mainly for iOS and Android.

Yep, no luck. With multiple versions.

If we must be gadgety with a web ui (I admit bias - I’m old school, if it doesn’t fallback to at least render text inall browsers - even ie - I wouldnt put it up - especially not simple documentation) - can we at least have an alternate URL with plain old HTML or even just ASCII text? My iPad displays that fine as well.

Yeah. I use Linux usually so having the API docs open in Chromium on my laptop while Codea is open on the iPad would be really handy.

“Uncaught TypeError: Property ‘scrollTo’ of object [object DOMWindow] is not a function” and you get a blank page. Boo on sencha for no fallback. To be fair, I guess it is an application framework.

It’s only using the Web UI because it’s designed to be displayed in-app from the keyboard popup, not really in a separate browser.

The best we can do is make the current JSON description available online for feeding into a different HTML output. I’ll look at doing that tomorrow.

Odd that it doesn’t work in Chrome though. It works in Chrome (Mac OS X) here. I thought Chrome rendered the same cross-platform.

I’d suggest you put the raw text (or an html render) into the wiki. That way bugs, comments, and example code could go in right alongside.

Good idea. The text is a bit unwieldy as it’s a nearly ~3000 line chunk of JSON.

This source is actually available here: http://twolivesleft.com/Codea/Reference/app/stores/reference.js

I’m happy to take suggestions on what to do with it.

heh - just the direct reference is good for the short term - I can display that page and search.

In the spirit of “Never have the devs do something we can do (and so allowing the devs to work on Codea itself”, I suggest you do nothing; we have the json. I may spend an hour and write a renderer that dumps it as wiki markup (or if I delay too long, someone else likely will), and then post it to the wiki, depending on if my wife and kids allow me a moment of peace. :slight_smile:

sigh…

 bortels@duo:~/dev/codify$ curl http://twolivesleft.com/Codea/Reference/app/stores/reference.js
<html>
<body>
<h3>This browser is unsupported. Please use a webkit browser such as Google Chrome or Apple's Safari</h3>
<body>
</html>

No big deal, used chrome to save it, but really - nothing should be checking browser type to simply download a javascript file. (My idea was to make a script that would dynamically fetch/translate the source, so that changes there would reflect in the new version automatically…)

ack - it is also not actually JSON (it’s simply javascript). Even removing the wrapper around it, the multiline entries with “+” at the end aren’t valid JSON - simply meaning this isn’t quite as simple at throwing it at a JSON parser then spitting out the data structure.

maybe I’ll just cheat and “eval” it in node.js :slight_smile:

Firefox’s user agent switcher comes to the rescue! One of the ones that I have installed (must be by default as I don’t remember installing it) is iPhone 3.0. Whereupon, I get the code.

On a serious point, when I first heard about Codify then I went to look at the documentation to get an idea of whether or not it would be suitable for what I wanted to do. Not being able to see the documentation meant that I initially dismissed it. It was really only the distinct lack of anything else out there that meant that I reconsidered it (it was either Codify or CBM64 Basic!). So the code documentation really, really ought to be readable anywhere.

And then I wonder why the forum suddenly looks very different … time to switch the user agent back to something sensible.

I made a start at:

https://bitbucket.org/TwoLivesLeft/codea/wiki/Documentation

I downloaded the file linked above, did a small amount of pre-processing:

cat documentation | perl -lne 's%//.*%%; s%(^\\s*)(\\w+): *%$1"$2" => %; s%^\\s*$%%; s/\\+\\s*$/. /; $_ and print;'

Modulo a bit of junk at the start, this turned the data structure into a perfectly valid perl data structure. The start needs to look like:

$doc = {'Reference' => {
    "model" => 'Library',
    "data" => {"libraries" => [
		   {

which means that the end has to read:

    "proxy" => {
        "type" => 'memory',
        "reader" => {
            "type" => 'json',
            "root" => 'libraries'
        }
    }
	}};

The rest of the code (which is highly hackish) is:

foreach $library (@{$doc->{"Reference"}{"data"}{"libraries"}}) {
    print &header(3,$library->{"name"}) . "\
";
    print &header(4,$library->{"subtitle"}) . "\
";
    foreach $fn (@{$library->{"functions"}}) {
	print &header(5,$fn->{"name"}) . "\
";
	if (defined $$fn{"examples"}) {
	    $numexs = @$fn{"examples"};
	    $title = "Example";
	    if ($numexs > 1) {
		$title .= "s";
	    }
	    print &header(6,$title) . "\
";
	    foreach $example (@{$fn->{"examples"}}) {
		($e = $example->{"example"}) =~ s/\\\
/\
/g;
		$e =~ s/\\\\t/\\t/g;
		print &code($e) . "\
";
	    }
	}

	print &header(6,"Description") . "\
";
	($d = $fn->{"description"}) =~ s/\\\
/\
/g;
	print &paragraph($d);
	if (defined $$fn{"syntax"}) {
	    print &header(6,"Syntax") . "\
";
	    ($s = $fn->{"syntax"}) =~ s/\\\
/\
/g;
	    print &code($s);
	    print "\
";
	}
	print &header(6,"Parameters") . "\
";
	print "\
";
	print &tableHeader("Name","Description") . "\
";
	foreach $parameter (@{$fn->{"parameters"}}) {
	    print &tableRow($parameter->{"name"},$parameter->{"description"}) . "\
";
	}
	print "\
";
	if (defined $$fn{"returns"}) {
	    print &header(6,"Returns") . "\
";
	    print &paragraph($fn->{"returns"});
	}
	if (defined $$fn{"related"}) {
	    print &header(6,"Related") . "\
";
	    foreach $related (@{$fn->{"related"}}) {
		print &list(&link($related));
	    }
	    print "\
";
	}
    }
}

sub header {
    my ($level,$text) = @_;
    return ("=" x $level) . $text . ("=" x $level);
}

sub paragraph {
    my ($text) = @_;
    return "\
\
" . $text . "\
\
";
}

sub code {
    my ($code) = @_;
    return "\
{{{\
" . $code . "\
}}}\
";
}

sub tableHeader {
    return "|=" . join("|=", @_) . "|";
}

sub tableRow {
    return "|" . join("|", @_) . "|";
}

sub link {
    my ($link) = @_;
    my $anchor = lc($link);
    $anchor =~ s/ /-/g;
    return '<a href="#!' . $anchor . '">' . $link . '</a>';
}

sub list {
    my ($text) = @_;
    return "\
# " . $text;
}

Great start, I had given up :slight_smile:

Wow forgot about the concatenation - sorry guys. Awesome little conversion, Andrew.

Ha! Andrew wins the “perl king” award for the day. I was about halfway that far when my 16-year-old informed me there was no possible was I could whip him in Age of Mythology, and, you know… Priorities.

Fortunately my kids a bit younger and just want to monopolise the iPad to see if they’ve managed to cross-breed a crocodile with a giraffe yet. So the main computer was free for a bit of perl.

I meant to break it down into smaller pages. I thought to check out the source via git and use the perl script to output separate pages, but I couldn’t get the checkout to work so I gave up on that.