All predicatesShow sourceexamples.pl -- Serve example files

Locate and serve files for the Examples menu as well as examples included from overview notebooks. The examples come from two sources:

This module also makes the known examples available through swish_provides/1 for supporting conditional statements on example overview notebooks.

Source list_examples(+Request)[private]
Get a list of registered example code. Examples are described in a file swish_examples('index.json').
Source examples(JSON:list, +Options) is det[private]
JSON is a list of JSON dicts containing the keys below. The list is composed from all *.pl files in the search path example.
  • file:File
  • href:URL
  • title:String
  • requires:Term
  • group:String
Source index_json(+BaseHREF, +Directory, -JSON)[private]
Produce a JSON description for the examples in the directory Dir. This deals with two scenarios: if a file index.json is provided, use this file and add the not-described files as examples that are not included in the menu. If no index.json is present, all files are added as example files.
Source add_examples_href(+HREF, +JSON0, -JSON) is det[private]
Add a href key pointing at the example. Also removes all items that are not dicts or have no file key.
Source ex_file_json(+ExampleBase, +Path, -JSON) is det[private]
Create a JSON representation for the given example file.
Source md_eval:provides(?Term) is nondet[multifile]
Make examples available through swish_provides/1. Can be used in dynamic cells as, e.g.,:
:- if(swish_provides(example('chat80.pl',_,_))).
...
:- endif.
Source community_examples(-Dict) is det[private]
Extract examples from the gitty store.