From 9dc520409905d7fc18bedd55e74d4cdbac4f38b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 24 Oct 2023 23:40:04 +0200 Subject: [PATCH] Use `clientstate` API --- docs/source/ceinclude.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/source/ceinclude.py b/docs/source/ceinclude.py index 348bc71af..198bff232 100644 --- a/docs/source/ceinclude.py +++ b/docs/source/ceinclude.py @@ -1,3 +1,6 @@ +import base64 +import json + from docutils import nodes from sphinx.directives.code import LiteralInclude, container_wrapper @@ -6,8 +9,27 @@ class CeIncludeDirective(LiteralInclude): def run(self): retnode = super().run()[0] - # paragraph_node = nodes.paragraph(text='Hello World!') - retnode = container_wrapper(self, retnode, "https://godbolt.org/z/q9h339vob") + _, filename = self.env.relfn2path(self.arguments[0]) + source = open(filename, "r").read() + client_state = { + "sessions": [ + { + "id": 1, + "language": "c++", + "source": source, + "compilers": [ + { + "id": "g132", + "options": "-O3", + "libs": [{'name': 'kokkos', 'ver': '4100'}], + } + ], + } + ] + } + encoded = base64.urlsafe_b64encode(json.dumps(client_state).encode()) + retnode = container_wrapper(self, retnode, "https://godbolt.org/clientstate/" + encoded.decode()) + # breakpoint() return [retnode] def setup(app):