From 2f00033683d9c7de55cdf91dac66b95766b8eb60 Mon Sep 17 00:00:00 2001
From: Lonami Exo
Date: Sun, 4 Jun 2017 19:57:20 +0200
Subject: [PATCH] Add a nice button to the docs to copy the import code
---
docs/docs_writer.py | 20 ++++++++++++++++++++
docs/generate.py | 11 +++++++++++
docs/res/css/docs.css | 30 ++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/docs/docs_writer.py b/docs/docs_writer.py
index 29bc2be4..202557ac 100644
--- a/docs/docs_writer.py
+++ b/docs/docs_writer.py
@@ -24,6 +24,7 @@ class DocsWriter:
self.menu_began = False
self.table_columns = 0
self.table_columns_left = None
+ self.write_copy_script = False
# High level writing
def write_head(self, title, relative_css_path):
@@ -232,8 +233,27 @@ class DocsWriter:
self.write(text)
self.write('
')
+ def write_copy_button(self, text, text_to_copy):
+ """Writes a button with 'text' which can be used
+ to copy 'text_to_copy' to clipboard when it's clicked."""
+ self.write_copy_script = True
+ self.write(''
+ .format(text_to_copy, text))
+
def end_body(self):
"""Ends the whole document. This should be called the last"""
+ if self.write_copy_script:
+ self.write(
+ ''
+ '')
+
self.write('