@@ -29,13 +29,15 @@ Synopsis...
- -  0 items  - - - - - +
+ +  0 items  + + + + + +
@@ -46,10 +48,12 @@
+

About

+

A basic tool for looking through scopes and quickly jumping to code within GF's resource grammar library (RGL), created out of necessity. All feedback is welcome.

+

Understanding the scope information

The scope information shown by this tool is basically the output of running GF with the --tags flag. This lists all the functions visible in the scope of a module, one per line. Each line can have two possible forms:

-

1. Local functions

mkPrep	oper-type	/lib/src/english/ParadigmsEng.gf:204	Str -> {s : Str; lock_Prep : {}}

For locally defined functions, the second column oper-type indicates the judgement type, followed by the location in the souce file and its type information.

@@ -75,10 +79,12 @@
scandinavian
Used by Danish, Norwegian, Swedish
-

About

-

A basic tool for looking up module scopes and quickly looking at module sources, created out of necessity. It is experimental and is known to hang when handling large files. All feedback is welcome.

+

Issues

-

Known issues and To-do

+

Something is missing or out of date

+

All the scoping information shown is not read directly from the RGL on-demand. There is an in-between processing stage which must be run, so if something seems out of date just let me know and I can udpate things manually.

+ +

To-Do

  • Some way of browsing just the API
  • The page sometimes stalls when handling large files (in particular the dictionary modules)
  • @@ -89,7 +95,7 @@
- John J. Camilleri. Updated 2012-05-25. + John J. Camilleri
Updated 2012-07-11
@@ -97,4 +103,4 @@ - \ No newline at end of file + diff --git a/lib/doc/browse/script.js b/lib/doc/browse/script.js index 199221d79..91bce60be 100644 --- a/lib/doc/browse/script.js +++ b/lib/doc/browse/script.js @@ -4,14 +4,60 @@ */ $(document).ready(function() { - var loadCount = 0; + // ===== State information ===== + + state = { + index: undefined, + lookup: {}, + loadCount: 0, + language: undefined, // lang of drop-down + current: { // current file + language: undefined, + module: undefined, + set: function(lang, module) { + state.current.language = lang; + state.current.module = module; + }, + equals: function(a, b) { + if (!b) + return (a == state.current.module); + else + return (a == state.current.language) && (b == state.current.module); + } + }, + title: "RGL Source Browser", + urlPrefix: "/", + defaultLangs: ['abstract','api','common','prelude'] + } ; + + var lookupModuleLanguage = function(module) { + var l = state.lookup[module]; + if (l==undefined || l.length==0) + return null; + else if (l.length==1) + return l[0]; + else { + for (i in l) { + if ($.inArray(l[i], state.defaultLangs)) + return l[i]; + } + return l[0]; // no preferred default, just return first... + } + } + var lookupAllModuleLanguages = function(module) { + return state.lookup[module]; + } + + + // ===== Utility/UI functions ===== + var showLoading = function(){ - loadCount++; + state.loadCount++; $("#loading").show(); } var hideLoading = function(){ - loadCount = Math.max(loadCount-1, 0); - if (loadCount == 0) + state.loadCount = Math.max(state.loadCount-1, 0); + if (state.loadCount == 0) $("#loading").hide(); } @@ -55,17 +101,57 @@ $(document).ready(function() { $('#code pre').html(code); prettyPrint(); } + var updateScopeCount = function(){ + $('#scope_count').text( $("#scope_list tr:visible").length ); + } - var current_language = undefined; - var urlPrefix = "/"; - var index; + var setLanguage = function(lang){ + state.language = lang; + $("#languages select").val(lang); + initModules(lang); + } + + // obj can be just a plain selector or a jQuery object + var showPanel = function(obj, callback){ + showLoading(); + setTimeout(function(){ + $(".panel:visible").hide(); + $(obj).show(0, callback); + recalculateHeights(); + updateScopeCount(); + hideLoading(); + }, 500); // this ensures the loading displays + } + var getPanel = function() { + return $('.panel:visible').first(); + } + + var setTitle = function(s){ + $('#tabbar h2').html(s); + $('title').html(state.title + ": " + s); + } + + + // ===== Initialization ===== + + // Load the index file and populate language & module lists $.ajax({ url: "index.json", dataType: "json", type: "GET", success: function(data) { - index = data; - if (data['urlprefix']) urlPrefix = data['urlprefix']; + state.index = data; + if (data['urlprefix']) state.urlPrefix = data['urlprefix']; + + // Build language lookup index + for (var lang in data['languages']) { + for (var i in data['languages'][lang]) { + var module = data['languages'][lang][i]; + if (!module) continue; + if (!state.lookup[module]) state.lookup[module] = []; + state.lookup[module].push(lang); + } + } // Initialize the language list var lang_select = $("