Skip to content

Commit

Permalink
Use clientstate API
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Oct 24, 2023
1 parent 91b9c73 commit 9dc5204
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions docs/source/ceinclude.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import base64
import json

from docutils import nodes
from sphinx.directives.code import LiteralInclude, container_wrapper

Expand All @@ -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):
Expand Down

0 comments on commit 9dc5204

Please sign in to comment.