aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2018-10-14 18:28:06 -0300
committerMatias Linares <matiaslina@gmail.com>2018-10-14 18:28:06 -0300
commit47aaf852798acb30f32f3e3ae7ca0fe28e9ac18e (patch)
treee34a61c32ceb72fb0af7b7e73a3b9fa57b93490b /scripts
parentee13d9e117fd82cf88c9bf28d6ce19b331aca1cb (diff)
downloadperl6-matrix-client-47aaf852798acb30f32f3e3ae7ca0fe28e9ac18e.tar.gz
Add script to get all endpoints for documentation.
Also the first endpoints.md with all the implemented methods
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/load-docs.p651
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/load-docs.p6 b/scripts/load-docs.p6
new file mode 100755
index 0000000..d3a1f81
--- /dev/null
+++ b/scripts/load-docs.p6
@@ -0,0 +1,51 @@
+#!/usr/bin/env perl6
+use v6;
+use HTTP::UserAgent;
+use JSON::Fast;
+
+sub get-api-docs {
+ my $url = "https://matrix.org/docs/api/client-server/json/api-docs.json";
+ my $ua = HTTP::UserAgent.new;
+
+ my $res = $ua.get($url);
+ die "Cannot get response $res" unless $res.is-success;
+
+ my $data = from-json($res.content);
+
+ my %tags;
+
+ for $data<paths> -> $path {
+ $path.kv.map: -> $p, $methods {
+ for $methods.kv -> $method, $description {
+ for $description<tags> -> $tag {
+ unless %tags{$tag}:exists {
+ %tags{$tag} = Array.new;
+ }
+ %tags{$tag}.push("{$method.uc} - $p");
+ }
+ }
+ }
+ }
+
+ %tags
+}
+
+sub MAIN(:$spec?) {
+ my %tags = get-api-docs;
+ for %tags.sort -> $pair {
+ my $tag = $pair.key;
+ my $methods = $pair.value;
+ say qq:to/EOF/;
+ # $tag
+ EOF
+
+ for $methods.Seq -> $m {
+ my Str $method = $m;
+ if $spec {
+ $method = $m.subst(/unstable/, $spec)
+ }
+ say "- [ ] " ~ $method;
+ }
+ say "";
+ }
+}