diff --git a/tools/odin-html-docs/footer.txt.html b/tools/odin-html-docs/footer.txt.html index fbed3146a..548a00995 100644 --- a/tools/odin-html-docs/footer.txt.html +++ b/tools/odin-html-docs/footer.txt.html @@ -5,8 +5,8 @@
- - Odin + + Odin

The Data-Oriented Language for Sane Software Development.

@@ -14,8 +14,8 @@
- - \ No newline at end of file + + + diff --git a/tools/odin-html-docs/header.txt.html b/tools/odin-html-docs/header.txt.html index cfa1e0175..4bb9036e2 100644 --- a/tools/odin-html-docs/header.txt.html +++ b/tools/odin-html-docs/header.txt.html @@ -3,32 +3,4 @@ - {0:s} - - - - - - - - - - -
- -
-
-
\ No newline at end of file + {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 570950dfb..79e9e4695 100644 --- a/tools/odin-html-docs/odin_html_docs_main.odin +++ b/tools/odin-html-docs/odin_html_docs_main.odin @@ -9,6 +9,7 @@ import "core:path/slashpath" import "core:sort" import "core:slice" +GITHUB_LICENSE_URL :: "https://github.com/odin-lang/Odin/tree/master/LICENSE" GITHUB_CORE_URL :: "https://github.com/odin-lang/Odin/tree/master/core" BASE_CORE_URL :: "/core" @@ -90,6 +91,7 @@ recursive_make_directory :: proc(path: string, prefix := "") { write_html_header :: proc(w: io.Writer, title: string) { fmt.wprintf(w, string(#load("header.txt.html")), title) + io.write(w, #load("header-lower.txt.html")) } write_html_footer :: proc(w: io.Writer, include_directory_js: bool) { @@ -289,19 +291,28 @@ generate_directory_tree :: proc() -> (root: ^Dir_Node) { } write_core_directory :: proc(w: io.Writer) { - root := generate_directory_tree() fmt.wprintln(w, `
`) defer fmt.wprintln(w, `
`) + { + fmt.wprintln(w, `
`) + fmt.wprintln(w, "
") + fmt.wprintln(w, "

Core Library Collection

") + fmt.wprintln(w, "
    ") + fmt.wprintf(w, "
  • License: BSD-3-Clause
  • \n", GITHUB_LICENSE_URL) + fmt.wprintf(w, "
  • Repository: {0:s}
  • \n", GITHUB_CORE_URL) + fmt.wprintln(w, "
") + fmt.wprintln(w, "
") + fmt.wprintln(w, "
") + fmt.wprintln(w, "
") + } fmt.wprintln(w, `
`) defer fmt.wprintln(w, `
`) - fmt.wprintln(w, "
") fmt.wprintln(w, "
") - fmt.wprintln(w, "

Core Library Collection

") + fmt.wprintln(w, `

Directories

`) fmt.wprintln(w, "
") - fmt.wprintln(w, "
") fmt.wprintln(w, "
") fmt.wprintln(w, "\t") @@ -802,57 +813,131 @@ write_docs :: proc(w: io.Writer, pkg: ^doc.Pkg, docs: string) { if docs == "" { return } - it := docs - was_code := true - was_paragraph := true - prev_line: string - for line in strings.split_iterator(&it, "\n") { - text := strings.trim_space(line) - defer prev_line = line + Block_Kind :: enum { + Paragraph, + Code, + } + Block :: struct { + kind: Block_Kind, + lines: []string, + } - if strings.has_prefix(line, "\t") { - if !was_code { - was_code = true; - if prev_line == "Example:" { - fmt.wprint(w, `
`)
-				} else {
-					fmt.wprint(w, `
`)
+	lines: [dynamic]string
+	it := docs
+	for line_ in strings.split_iterator(&it, "\n") {
+		line := strings.trim_right_space(line_)
+		append(&lines, line)
+	}
+
+	curr_block_kind := Block_Kind.Paragraph
+	start := 0
+	blocks: [dynamic]Block
+
+	for line, i in lines {
+		text := strings.trim_space(line)
+		switch curr_block_kind {
+		case .Paragraph:
+			if strings.has_prefix(line, "\t") {
+				if i-start > 0 {
+					append(&blocks, Block{curr_block_kind, lines[start:i]})
 				}
+				curr_block_kind, start = .Code, i
+			} else if text == "" {
+				if i-start > 0 {
+					append(&blocks, Block{curr_block_kind, lines[start:i]})
+				}
+				start = i
 			}
-			fmt.wprintf(w, "%s\n", strings.trim_prefix(line, "\t"))
-			continue
-		} else if was_code {
-			if text == "" {
+		case .Code:
+			if text == "" || strings.has_prefix(line, "\t") {
 				continue
 			}
-			was_code = false
-			fmt.wprintln(w, "
") - } - if text == "" { - if was_paragraph { - was_paragraph = false - fmt.wprintln(w, "

") + if i-start > 0 { + append(&blocks, Block{curr_block_kind, lines[start:i]}) } + curr_block_kind, start = .Paragraph, i + } + } + if start < len(lines) { + if len(lines)-start > 0 { + append(&blocks, Block{curr_block_kind, lines[start:]}) + } + } + + for block in &blocks { + trim_amount := 0 + for trim_amount = 0; trim_amount < len(block.lines); trim_amount += 1 { + line := block.lines[trim_amount] + if strings.trim_space(line) != "" { + break + } + } + block.lines = block.lines[trim_amount:] + } + + for block, i in blocks { + if len(block.lines) == 0 { continue } - if !was_paragraph { - fmt.wprintln(w, "

") + prev_line := "" + if i > 0 { + prev_lines := blocks[i-1].lines + if len(prev_lines) > 0 { + prev_line = prev_lines[len(prev_lines)-1] + } } - assert(!was_code) + prev_line = strings.trim_space(prev_line) - was_paragraph = true - write_doc_line(w, text) + lines := block.lines[:] - io.write_byte(w, '\n') - } - if was_code { - // assert(!was_paragraph, str(pkg.name)) - was_code = false - fmt.wprintln(w, "

") - } - if was_paragraph { - fmt.wprintln(w, "

") + end_line := block.lines[len(lines)-1] + if block.kind == .Paragraph && i+1 < len(blocks) { + if strings.has_prefix(end_line, "Example:") && blocks[i+1].kind == .Code { + lines = lines[:len(lines)-1] + } + } + + switch block.kind { + case .Paragraph: + io.write_string(w, "

") + for line, line_idx in lines { + if line_idx > 0 { + io.write_string(w, "\n") + } + io.write_string(w, line) + } + io.write_string(w, "

\n") + case .Code: + all_blank := len(lines) > 0 + for line in lines { + if strings.trim_space(line) != "" { + all_blank = false + } + } + if all_blank { + continue + } + + if strings.has_prefix(prev_line, "Example:") { + io.write_string(w, "
\n") + defer io.write_string(w, "
\n") + io.write_string(w, "Example:\n") + io.write_string(w, `
`)
+				for line in lines {
+					io.write_string(w, strings.trim_prefix(line, "\t"))
+					io.write_string(w, "\n")
+				}
+				io.write_string(w, "
\n") + } else { + io.write_string(w, "
")
+				for line in lines {
+					io.write_string(w, strings.trim_prefix(line, "\t"))
+					io.write_string(w, "\n")
+				}
+				io.write_string(w, "
\n") + } + } } } @@ -860,7 +945,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { fmt.wprintln(w, `
`) defer fmt.wprintln(w, `
`) - fmt.wprintln(w, `
`) + fmt.wprintln(w, `
`) { // breadcrumbs fmt.wprintln(w, `
`) @@ -907,9 +992,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { } fmt.wprintln(w, `

Index

`) - fmt.wprintln(w, `
`) - // 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 @@ -944,8 +1027,16 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { slice.sort_by_key(pkg_consts[:], entity_key) write_index :: proc(w: io.Writer, name: string, entities: []^doc.Entity) { - fmt.wprintf(w, "

%s

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

This section is empty.

\n") } else { @@ -956,7 +1047,6 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { } fmt.wprintln(w, "") } - fmt.wprintln(w, "
") } entity_ordering := [?]struct{name: string, entities: []^doc.Entity} { @@ -972,7 +1062,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { write_index(w, eo.name, eo.entities) } - fmt.wprintln(w, "
") + fmt.wprintln(w, "
") write_entity :: proc(w: io.Writer, e: ^doc.Entity) { @@ -1008,6 +1098,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { fmt.wprintf(w, "", src_url) } fmt.wprintf(w, "\n") + fmt.wprintln(w, `
`) switch e.kind { case .Invalid, .Import_Name, .Library_Name: @@ -1048,7 +1139,7 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { init_string := str(e.init_string) if init_string != "" { io.write_string(w, " = ") - io.write_string(w, init_string) + io.write_string(w, "…") } fmt.wprintln(w, "") @@ -1099,8 +1190,15 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { fmt.wprintln(w, "") } + fmt.wprintln(w, `
`) - write_docs(w, pkg, strings.trim_space(str(e.docs))) + the_docs := strings.trim_space(str(e.docs)) + if the_docs != "" { + fmt.wprintln(w, `
`) + fmt.wprintln(w, ` `) + write_docs(w, pkg, the_docs) + fmt.wprintln(w, `
`) + } } write_entities :: proc(w: io.Writer, title: string, entities: []^doc.Entity) { fmt.wprintf(w, "

{0:s}

\n", title) @@ -1109,7 +1207,9 @@ write_pkg :: proc(w: io.Writer, path: string, pkg: ^doc.Pkg) { io.write_string(w, "

This section is empty.

\n") } else { for e in entities { + fmt.wprintln(w, `
`) write_entity(w, e) + fmt.wprintln(w, `
`) } } fmt.wprintln(w, "") diff --git a/tools/odin-html-docs/style.css b/tools/odin-html-docs/style.css index cf3782c5d..c4f4c5ebf 100644 --- a/tools/odin-html-docs/style.css +++ b/tools/odin-html-docs/style.css @@ -25,10 +25,6 @@ table.`directory { padding-right: 0; } -.doc-directory tr[aria-controls]:hover { - background-color: #eee; -} - .doc-directory tr[aria-expanded=true] td.pkg-name:before { content: "\2193"; } @@ -57,12 +53,12 @@ pre.doc-code { pre.doc-code a { font-family: Consolas,Liberation Mono,Menlo,monospace!important; text-decoration: none; - /*font-weight: bold;*/ - color: #00bfd5; + color: #2179d8; + font-weight: 800; } pre.doc-code a.code-procedure { - color: #079300; + color: #047919; } .pkg-line-doc { @@ -90,18 +86,48 @@ a > .a-hidden { a:hover > .a-hidden { opacity: 100; } - -article.documentation h2 { - border-bottom: 1px dashed #c6c8ca; - padding-bottom: 0.5rem; -} section.documentation h3 { font-size: calc(1.1rem + .2vw); } +.pkg-index h3 { + margin-top: 0 !important; + padding-top: 0 !important; +} -.doc-index h3 { - border-bottom: 1px solid #c6c8ca; - padding-bottom: 0.25rem; +.documentation .pkg-entity { + padding-bottom: 0.75rem; + border-bottom: 1px solid #d0d0d0; +} + +details.doc-index > summary { + position: relative; + font-size: 1.75rem; + left: -1.75rem; +} +details.doc-index ul { + list-style-type: none; +} + + +.odin-doc-toggle { + +} + +details.odin-doc-toggle[open] > summary.hideme { + margin-bottom: 0.5em; +} + +details.odin-doc-toggle > summary.hideme { + cursor: pointer; +} + +details.odin-doc-toggle[open] > summary.hideme span { + content: ""; +} + + +details.code-example > summary { + font-weight: 700; } \ No newline at end of file