From db08847f9ab8090c246f678b3b440fc3e6aacd4c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Jan 2022 13:20:38 +0000 Subject: [PATCH] Improve rendering to match the main website's CSS --- tools/odin-html-docs/footer.txt.html | 43 ++++ tools/odin-html-docs/header.txt.html | 34 +++ tools/odin-html-docs/odin_html_docs_main.odin | 226 +++++++++++------- tools/odin-html-docs/style.css | 89 ++----- 4 files changed, 241 insertions(+), 151 deletions(-) create mode 100644 tools/odin-html-docs/footer.txt.html create mode 100644 tools/odin-html-docs/header.txt.html diff --git a/tools/odin-html-docs/footer.txt.html b/tools/odin-html-docs/footer.txt.html new file mode 100644 index 000000000..fbed3146a --- /dev/null +++ b/tools/odin-html-docs/footer.txt.html @@ -0,0 +1,43 @@ + + + + + + + \ No newline at end of file diff --git a/tools/odin-html-docs/header.txt.html b/tools/odin-html-docs/header.txt.html new file mode 100644 index 000000000..cfa1e0175 --- /dev/null +++ b/tools/odin-html-docs/header.txt.html @@ -0,0 +1,34 @@ + + + + + + {0:s} + + + + + + + + + + +
+ +
+
+
\ No newline at end of file diff --git a/tools/odin-html-docs/odin_html_docs_main.odin b/tools/odin-html-docs/odin_html_docs_main.odin index 317d95a5a..a6b5f428e 100644 --- a/tools/odin-html-docs/odin_html_docs_main.odin +++ b/tools/odin-html-docs/odin_html_docs_main.odin @@ -88,71 +88,62 @@ recursive_make_directory :: proc(path: string, prefix := "") { write_html_header :: proc(w: io.Writer, title: string) { - fmt.wprintf(w, ` - - - - - %s - - - - - - -`, title) - fmt.wprintln(w, "\n
") - fmt.wprintln(w, "\nCore Directory") - + fmt.wprintf(w, string(#load("header.txt.html")), title) } -write_html_footer :: proc(w: io.Writer) { - io.write_string(w, ` - -`) - fmt.wprintf(w, "
\n\n") + } + doc.addEventListener('click', toggle, false); +}(this, this.document)); +`) + } + + fmt.wprintf(w, "\n\n") } main :: proc() { @@ -220,7 +211,7 @@ main :: proc() { strings.reset_builder(&b) write_html_header(w, "core library - pkg.odin-lang.org") write_core_directory(w) - write_html_footer(w) + write_html_footer(w, true) os.make_directory("core", 0) os.write_entire_file("core/index.html", b.buf[:]) } @@ -229,7 +220,7 @@ main :: proc() { strings.reset_builder(&b) write_html_header(w, fmt.tprintf("package %s - pkg.odin-lang.org", path)) write_pkg(w, path, pkg) - write_html_footer(w) + write_html_footer(w, false) recursive_make_directory(path, "core") os.write_entire_file(fmt.tprintf("core/%s/index.html", path), b.buf[:]) } @@ -297,10 +288,19 @@ write_core_directory :: proc(w: io.Writer) { } } + fmt.wprintln(w, `
`) + defer fmt.wprintln(w, `
`) + fmt.wprintln(w, `
`) + defer fmt.wprintln(w, `
`) - fmt.wprintln(w, "

Directories

") + fmt.wprintln(w, "
") + fmt.wprintln(w, "
") + fmt.wprintln(w, "

Core Library Collection

") + fmt.wprintln(w, "
") + fmt.wprintln(w, "
") - fmt.wprintln(w, "\t") + fmt.wprintln(w, "
") + fmt.wprintln(w, "\t
") fmt.wprintln(w, "\t\t") for dir := root.first_child; dir != nil; dir = dir.next { @@ -356,6 +356,7 @@ write_core_directory :: proc(w: io.Writer) { fmt.wprintln(w, "\t\t") fmt.wprintln(w, "\t
") + fmt.wprintln(w, "
") } is_entity_blank :: proc(e: doc.Entity_Index) -> bool { @@ -817,23 +818,42 @@ write_docs :: proc(w: io.Writer, pkg: ^doc.Pkg, docs: string) { } write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { - write_breadcrumbs :: proc(w: io.Writer, path: string) { - dirs := strings.split(path, "/") - io.write_string(w, "\n") + fmt.wprintln(w, ``) + fmt.wprintln(w, ``) } - write_breadcrumbs(w, fmt.tprintf("core/%s", path)) + fmt.wprintln(w, `
`) fmt.wprintf(w, "

package core:%s

\n", path) fmt.wprintln(w, "

Documentation

") @@ -847,7 +867,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { } fmt.wprintln(w, "

Index

") - fmt.wprintln(w, `
`) + fmt.wprintln(w, `
`) pkg_procs: [dynamic]^doc.Entity pkg_proc_groups: [dynamic]^doc.Entity pkg_types: [dynamic]^doc.Entity @@ -883,7 +903,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { write_index :: proc(w: io.Writer, name: string, entities: []^doc.Entity) { fmt.wprintf(w, "

%s

\n", name) - fmt.wprintln(w, `
`) + fmt.wprintln(w, `
`) if len(entities) == 0 { io.write_string(w, "

This section is empty.

\n") } else { @@ -933,11 +953,11 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { name := str(e.name) path := pkg_to_path[pkg] filename := slashpath.base(str(files[e.pos.file].name)) - fmt.wprintf(w, "

{0:s}", name) + fmt.wprintf(w, "

{0:s}", name) fmt.wprintf(w, " ¶") if e.pos.file != 0 && e.pos.line > 0 { src_url := fmt.tprintf("%s/%s/%s#L%d", GITHUB_CORE_URL, path, filename, e.pos.line) - fmt.wprintf(w, "", src_url) + fmt.wprintf(w, "", src_url) } fmt.wprintf(w, "

\n") @@ -945,7 +965,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { case .Invalid, .Import_Name, .Library_Name: // ignore case .Constant: - fmt.wprint(w, "
")
+			fmt.wprint(w, `
`)
 			the_type := types[e.type]
 
 			init_string := str(e.init_string)
@@ -973,7 +993,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) {
 			io.write_string(w, init_string)
 			fmt.wprintln(w, "
") case .Variable: - fmt.wprint(w, "
")
+			fmt.wprint(w, `
`)
 			write_attributes(w, e)
 			fmt.wprintf(w, "%s: ", name)
 			write_type(writer, types[e.type], {.Allow_Indent})
@@ -985,7 +1005,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) {
 			fmt.wprintln(w, "
") case .Type_Name: - fmt.wprint(w, "
")
+			fmt.wprint(w, `
`)
 			fmt.wprintf(w, "%s :: ", name)
 			the_type := types[e.type]
 			type_to_print := the_type
@@ -1004,14 +1024,14 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) {
 			write_type(writer, type_to_print, {.Allow_Indent})
 			fmt.wprintln(w, "
") case .Procedure: - fmt.wprint(w, "
")
+			fmt.wprint(w, `
`)
 			fmt.wprintf(w, "%s :: ", name)
 			write_type(writer, types[e.type], nil)
 			write_where_clauses(w, array(e.where_clauses))
 			fmt.wprint(w, " {…}")
 			fmt.wprintln(w, "
") case .Proc_Group: - fmt.wprint(w, "
")
+			fmt.wprint(w, `
`)
 			fmt.wprintf(w, "%s :: proc{{\n", name)
 			for entity_index in array(e.grouped_entities) {
 				this_proc := &entities[entity_index]
@@ -1035,7 +1055,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) {
 		write_docs(w, pkg, strings.trim_space(str(e.docs)))
 	}
 	write_entities :: proc(w: io.Writer, title: string, entities: []^doc.Entity) {
-		fmt.wprintf(w, "

%s

\n", title) + fmt.wprintf(w, "

{0:s}

\n", title) fmt.wprintln(w, `
`) if len(entities) == 0 { io.write_string(w, "

This section is empty.

\n") @@ -1054,7 +1074,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { write_entities(w, "Constants", pkg_consts[:]) - fmt.wprintln(w, "

Source Files

") + fmt.wprintln(w, `

Source Files

`) fmt.wprintln(w, "
    ") any_hidden := false source_file_loop: for file_index in array(pkg.files) { @@ -1087,4 +1107,38 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { } fmt.wprintln(w, "
") + + fmt.wprintln(w, `

`) + { + write_link :: proc(w: io.Writer, id, text: string) { + fmt.wprintf(w, `
  • %s`, id, text) + } + + write_index :: proc(w: io.Writer, name: string, entities: []^doc.Entity) { + fmt.wprintf(w, `
  • {0:s}`, name) + fmt.wprintln(w, `
      `) + for e in entities { + name := str(e.name) + fmt.wprintf(w, "
    • {0:s}
    • \n", name) + } + fmt.wprintln(w, "
    ") + fmt.wprintln(w, "
  • ") + } + + + fmt.wprintln(w, ``) + } + } \ No newline at end of file diff --git a/tools/odin-html-docs/style.css b/tools/odin-html-docs/style.css index c83a046a8..1972e99e1 100644 --- a/tools/odin-html-docs/style.css +++ b/tools/odin-html-docs/style.css @@ -1,26 +1,18 @@ -html { - font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; -} +/* doc directories */ -.container { - max-width: 60em; - margin: 0 auto; - padding-left: 0.01em 1em; -} - -table.documentation-directory { +table.doc-directory { /*border: 1px solid #ccc!important;*/ table-layout: fixed; border-collapse: collapse; } -.documentation-directory tr { +.doc-directory tr { padding-left: 1em!important; border-top: 1px solid #ccc!important; border-bottom: 1px solid #ccc!important; } -.documentation-directory td { +.doc-directory td { padding: 0.25em 0.5em; } .directory-child td { @@ -32,59 +24,62 @@ table.documentation-directory { left: -1.5em!important; padding-right: 0; } -.pkg-line-doc { - color: #444; -} -.documentation-directory tr[aria-controls]:hover { +.doc-directory tr[aria-controls]:hover { background-color: #eee; } -.documentation-directory tr[aria-expanded=true] td.pkg-name:before { +.doc-directory tr[aria-expanded=true] td.pkg-name:before { content: "\2193"; } -.documentation-directory tr[aria-expanded=false] td.pkg-name:before { +.doc-directory tr[aria-expanded=false] td.pkg-name:before { content: "\2192"!important; } -.documentation-directory tr[aria-hidden=true] { +.doc-directory tr[aria-hidden=true] { display: none; } -pre { + +/* doc page */ + +pre.doc-code { white-space: pre-wrap; word-break: keep-all; word-wrap: break-word; tab-size: 8; - font-family: Consolas,Liberation Mono,Menlo,monospace!important; background-color: #f8f8f8; color: #202224; border: 1px solid #c6c8ca; border-radius: 0.25rem; padding: 0.625rem; } - -pre a { +pre.doc-code a { font-family: Consolas,Liberation Mono,Menlo,monospace!important; text-decoration: none; /*font-weight: bold;*/ color: #00bfd5; } -.documentation pre a.code-procedure { +pre.doc-code a.code-procedure { color: #079300; } -.documentation-source { +.pkg-line-doc { + color: #444; +} + + +.doc-source { display: inline; float: right; } -.documentation-source a { +.doc-source a { text-decoration: none; color: #666666; } -.documentation-source a:hover { +.doc-source a:hover { text-decoration: underline; } @@ -95,42 +90,6 @@ a:hover > .a-hidden { opacity: 100; } -ul.documentation-breadcrumb { - list-style: none; -} - -ul.documentation-breadcrumb li { - display: inline; -} - -ul.documentation-breadcrumb li+li:before { - padding: 0.2rem; - color: black; - content: "/\00a0"; -} - -.code-inline { - font-family: Consolas,Liberation Mono,Menlo,monospace!important; - background-color: #f8f8f8; - color: #202224; - border: 1px solid #c6c8ca; - border-radius: 0.25rem; - padding: 0.125rem; -} - -.documentation-directory { - width: 100%; -} - -.documentation-directory tr { - /*background-color: #999;*/ -} - - -.documentation-directory tr[aria-controls] { - cursor: pointer; -} - -.documentation-directory tr.hidden { - display: none; +.documentation h4 { + font-size: calc(1.1rem + .2vw); } \ No newline at end of file