From 220a8b398129131f0abc4eb0afeedfce661b3cb3 Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Thu, 29 Aug 2024 23:46:46 -0400 Subject: [PATCH] generate HTML header tags --- libs/wingc/src/generate_docs.rs | 50 +++++++++++++++------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/libs/wingc/src/generate_docs.rs b/libs/wingc/src/generate_docs.rs index 38008f5f368..68e286a8b6b 100644 --- a/libs/wingc/src/generate_docs.rs +++ b/libs/wingc/src/generate_docs.rs @@ -156,7 +156,7 @@ fn generate_docs_helper(types: &Types, project_dir: &Utf8Path) -> Result panic!("Error in root env: {}", diag), }; - docs.push_str("## API Reference\n\n"); + docs.push_str("

API Reference

\n\n"); let mut public_types = vec![]; let namespaces = find_documentable_namespaces_recursive(&ns); @@ -220,7 +220,7 @@ fn simplified_fqn(typ: &TypeRef) -> String { } fn print_table_of_contents(types: &[TypeRef], docs: &mut String) { - docs.push_str("### Table of Contents\n\n"); + docs.push_str("

Table of Contents

\n\n"); let mut classes = vec![]; let mut interfaces = vec![]; @@ -287,13 +287,13 @@ fn print_table_of_contents(types: &[TypeRef], docs: &mut String) { fn print_classes(types: &[TypeRef], docs: &mut String) { for typ in types { if let Type::Class(ref class) = **typ { - docs.push_str("### "); + docs.push_str("

"); docs.push_str(&simplified_fqn(typ)); docs.push_str(" ("); docs.push_str(&class.phase.to_string()); - docs.push_str(" class) \n\n"); + docs.push_str(" class)

\n\n"); let docstring = class.docs.render(); if !docstring.is_empty() { @@ -311,13 +311,11 @@ fn print_classes(types: &[TypeRef], docs: &mut String) { fn print_interfaces(types: &[TypeRef], docs: &mut String) { for typ in types { if let Type::Interface(ref interface) = **typ { - docs.push_str("### "); - docs.push_str(&simplified_fqn(typ)); - docs.push_str(" (interface) \n\n"); + docs.push_str("\">"); + docs.push_str(&simplified_fqn(typ)); + docs.push_str(" (interface)\n\n"); let docstring = interface.docs.render(); if !docstring.is_empty() { @@ -334,13 +332,11 @@ fn print_interfaces(types: &[TypeRef], docs: &mut String) { fn print_structs(types: &[TypeRef], docs: &mut String) { for typ in types { if let Type::Struct(ref struct_) = **typ { - docs.push_str("### "); - docs.push_str(&simplified_fqn(typ)); - docs.push_str(" (struct) \n\n"); + docs.push_str("\">"); + docs.push_str(&simplified_fqn(typ)); + docs.push_str(" (struct)\n\n"); let docstring = struct_.docs.render(); if !docstring.is_empty() { @@ -356,13 +352,11 @@ fn print_structs(types: &[TypeRef], docs: &mut String) { fn print_enums(types: &[TypeRef], docs: &mut String) { for typ in types { if let Type::Enum(ref enum_) = **typ { - docs.push_str("### "); - docs.push_str(&simplified_fqn(typ)); - docs.push_str(" (enum) \n\n"); + docs.push_str("\">"); + docs.push_str(&simplified_fqn(typ)); + docs.push_str(" (enum)\n\n"); let docstring = enum_.docs.render(); if !docstring.is_empty() { @@ -370,7 +364,7 @@ fn print_enums(types: &[TypeRef], docs: &mut String) { docs.push_str("\n\n"); } - docs.push_str("#### Values\n\n"); + docs.push_str("

Values

\n\n"); docs.push_str("| **Name** | **Description** |\n"); docs.push_str("| --- | --- |\n"); for (name, description) in enum_.values.iter() { @@ -391,7 +385,7 @@ fn print_enums(types: &[TypeRef], docs: &mut String) { } fn print_constructors(docs: &mut String, class: &impl ClassLike) { - docs.push_str("#### Constructor\n\n"); + docs.push_str("

Constructor

\n\n"); let mut constructors = class.constructors(true).collect::>(); constructors.retain(|(_, constructor_info)| constructor_info.access == AccessModifier::Public); @@ -417,7 +411,7 @@ fn print_constructors(docs: &mut String, class: &impl ClassLike) { } fn print_properties(docs: &mut String, class: &impl ClassLike) { - docs.push_str("#### Properties\n\n"); + docs.push_str("

Properties

\n\n"); let mut fields = class.fields(true).collect::>(); fields.retain(|(_, field_info)| field_info.access == AccessModifier::Public); @@ -447,7 +441,7 @@ fn print_properties(docs: &mut String, class: &impl ClassLike) { } fn print_methods(docs: &mut String, class: &impl ClassLike) { - docs.push_str("#### Methods\n\n"); + docs.push_str("

Methods

\n\n"); let mut methods = class.methods(true).collect::>(); methods.retain(|(_, method_info)| method_info.access == AccessModifier::Public);