瀏覽代碼

Playground: Add help documentation

Brendan Coles 4 年之前
父節點
當前提交
1f03b6ad57

+ 28 - 0
Base/usr/share/man/man1/Playground.md

@@ -0,0 +1,28 @@
+## Name
+
+Playground - GUI Markup Language (GML) editor
+
+## Synopsis
+
+```**sh
+$ Playground
+```
+
+## Description
+
+Playground facilitates development of graphical user interfaces (GUI)
+for Serenity applications using GUI Markup Language (GML) to compose
+a layout for GUI widgets and set widget attributes.
+
+The specified widgets are automatically rendered in a live preview
+window, allowing rapid prototyping and development of application GUIs.
+
+## Examples
+
+```sh
+$ Playground
+```
+
+## See also
+
+* [`gml-format`(1)](../man1/gml-format.md) For automated GML formatting

+ 23 - 0
Base/usr/share/man/man1/gml-format.md

@@ -0,0 +1,23 @@
+## Name
+
+gml-format - automated GUI Markup Language (GML) formatter
+
+## Synopsis
+
+```**sh
+$ gml-format [--inplace] [path...]
+```
+
+## Description
+
+`gml-format` formats GUI Markup Language (GML) files.
+
+## Options
+
+* `-i`, `--inplace`: Write formatted contents back to file rather than standard output
+
+## Examples
+
+```sh
+$ gml-format -i /home/anon/example.gml
+```

+ 1 - 1
DevTools/Playground/CMakeLists.txt

@@ -3,4 +3,4 @@ set(SOURCES
 )
 
 serenity_app(Playground ICON app-playground)
-target_link_libraries(Playground LibGUI)
+target_link_libraries(Playground LibDesktop LibGUI)

+ 18 - 0
DevTools/Playground/main.cpp

@@ -25,8 +25,10 @@
  */
 
 #include <AK/QuickSort.h>
+#include <AK/URL.h>
 #include <LibCore/File.h>
 #include <LibCore/Property.h>
+#include <LibDesktop/Launcher.h>
 #include <LibGUI/AboutDialog.h>
 #include <LibGUI/Application.h>
 #include <LibGUI/AutocompleteProvider.h>
@@ -231,6 +233,19 @@ int main(int argc, char** argv)
 
     auto app = GUI::Application::construct(argc, argv);
 
+    if (pledge("stdio thread shared_buffer accept rpath cpath wpath unix", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
+    if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
+            "/bin/Help",
+            { URL::create_with_file_protocol("/usr/share/man/man1/Playground.md") })
+        || !Desktop::Launcher::seal_allowlist()) {
+        warnln("Failed to set up allowed launch URLs");
+        return 1;
+    }
+
     if (pledge("stdio thread shared_buffer accept rpath cpath wpath", nullptr) < 0) {
         perror("pledge");
         return 1;
@@ -331,6 +346,9 @@ int main(int argc, char** argv)
     }));
 
     auto& help_menu = menubar->add_menu("Help");
+    help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) {
+        Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/Playground.md"), "/bin/Help");
+    }));
     help_menu.add_action(GUI::Action::create("About", [&](auto&) {
         GUI::AboutDialog::show("GML Playground", app_icon.bitmap_for_size(32), window);
     }));