generate-nav-simple.jl
1 #!/usr/bin/env julia 2 3 """ 4 Simple Navigation Generator 5 6 Generates navigation elements without external dependencies. 7 Uses the navigation configuration defined in navigation-config.md. 8 """ 9 10 # Navigation data structure (manually maintained based on navigation-config.md) 11 const NAVIGATION = Dict( 12 "getting_started" => Dict( 13 "title" => "Getting Started", 14 "icon" => "🚀", 15 "path" => "getting-started/", 16 "description" => "New to Planar? Start here", 17 "order" => 1, 18 "pages" => [ 19 ("index", "Overview", "Getting started overview and path selection", 1), 20 ("installation", "Installation", "Install Planar and dependencies", 2, "10 min"), 21 ("quick-start", "Quick Start", "Get up and running in 15 minutes", 3, "15 min"), 22 ("first-strategy", "First Strategy", "Build your first trading strategy", 4, "20 min") 23 ], 24 "next_section" => "guides" 25 ), 26 "guides" => Dict( 27 "title" => "Development Guides", 28 "icon" => "📚", 29 "path" => "guides/", 30 "description" => "Build trading strategies", 31 "order" => 2, 32 "pages" => [ 33 ("index", "Overview", "Guide overview and topics", 1), 34 ("strategy-development", "Strategy Development", "Core development guide", 2, "45 min"), 35 ("data-management", "Data Management", "Working with market data", 3, "30 min"), 36 ("execution-modes", "Execution Modes", "Sim, Paper, and Live trading", 4, "25 min"), 37 ("optimization", "Optimization", "Parameter tuning and optimization", 5, "35 min"), 38 ("visualization", "Visualization", "Plotting and analysis", 6, "20 min") 39 ], 40 "next_section" => "advanced" 41 ), 42 "advanced" => Dict( 43 "title" => "Advanced Topics", 44 "icon" => "⚡", 45 "path" => "advanced/", 46 "description" => "Advanced usage and customization", 47 "order" => 3, 48 "pages" => [ 49 ("index", "Overview", "Advanced topics overview", 1), 50 ("customization", "Customization", "Extending Planar functionality", 2, "40 min"), 51 ("margin-trading", "Margin Trading", "Advanced trading features", 3, "30 min"), 52 ("multi-exchange", "Multi-Exchange", "Complex multi-exchange setups", 4, "35 min"), 53 ("performance", "Performance", "Optimization and scaling", 5, "25 min") 54 ], 55 "next_section" => "reference" 56 ), 57 "reference" => Dict( 58 "title" => "API Reference", 59 "icon" => "📖", 60 "path" => "reference/", 61 "description" => "Complete function documentation", 62 "order" => 4, 63 "pages" => [ 64 ("index", "Overview", "API reference overview", 1), 65 ("configuration", "Configuration", "All configuration options", 2), 66 ("types", "Types", "Type system reference", 3) 67 ], 68 "next_section" => "troubleshooting" 69 ), 70 "troubleshooting" => Dict( 71 "title" => "Troubleshooting", 72 "icon" => "🔧", 73 "path" => "troubleshooting/", 74 "description" => "Problem resolution", 75 "order" => 5, 76 "pages" => [ 77 ("index", "Overview", "Problem categories and quick fixes", 1), 78 ("installation-issues", "Installation Issues", "Setup and dependency problems", 2), 79 ("strategy-problems", "Strategy Problems", "Strategy development issues", 3), 80 ("performance-issues", "Performance Issues", "Speed and memory problems", 4), 81 ("exchange-issues", "Exchange Issues", "Connection and API problems", 5) 82 ], 83 "next_section" => "resources" 84 ), 85 "resources" => Dict( 86 "title" => "Resources", 87 "icon" => "📚", 88 "path" => "resources/", 89 "description" => "Additional materials", 90 "order" => 6, 91 "pages" => [ 92 ("index", "Overview", "Available resources", 1), 93 ("glossary", "Glossary", "Terms and concepts", 2), 94 ("migration-guides", "Migration Guides", "Version update guides", 3), 95 ("community", "Community", "Support and contacts", 4) 96 ] 97 ) 98 ) 99 100 const USER_JOURNEYS = Dict( 101 "new_user" => Dict( 102 "title" => "New to Planar", 103 "description" => "Complete beginner path", 104 "time" => "90 minutes", 105 "path" => [ 106 "getting-started/installation", 107 "getting-started/quick-start", 108 "getting-started/first-strategy", 109 "guides/strategy-development" 110 ] 111 ), 112 "strategy_developer" => Dict( 113 "title" => "Strategy Developer", 114 "description" => "Focus on building strategies", 115 "time" => "3 hours", 116 "path" => [ 117 "guides/strategy-development", 118 "guides/data-management", 119 "guides/execution-modes", 120 "guides/optimization", 121 "advanced/customization" 122 ] 123 ), 124 "advanced_user" => Dict( 125 "title" => "Advanced User", 126 "description" => "Customization and scaling", 127 "time" => "2.5 hours", 128 "path" => [ 129 "advanced/customization", 130 "advanced/margin-trading", 131 "advanced/multi-exchange", 132 "advanced/performance", 133 "reference/api/core" 134 ] 135 ), 136 "troubleshooter" => Dict( 137 "title" => "Need Help", 138 "description" => "Problem resolution", 139 "time" => "30 minutes", 140 "path" => [ 141 "troubleshooting/index", 142 "troubleshooting/installation-issues", 143 "troubleshooting/strategy-problems", 144 "resources/community" 145 ] 146 ) 147 ) 148 149 """ 150 Generate main navigation menu 151 """ 152 function generate_main_menu() 153 sections = sort(collect(NAVIGATION), by=x -> x[2]["order"]) 154 155 menu = "# Planar Documentation\n\n" 156 157 for (key, section) in sections 158 icon = section["icon"] 159 title = section["title"] 160 description = section["description"] 161 path = section["path"] 162 163 menu *= """ 164 ## $icon $title 165 166 $description 167 168 [Explore $title]($path) 169 170 """ 171 end 172 173 return menu 174 end 175 176 """ 177 Generate section menu 178 """ 179 function generate_section_menu(section_key) 180 if !haskey(NAVIGATION, section_key) 181 return "Section not found: $section_key" 182 end 183 184 section = NAVIGATION[section_key] 185 pages = section["pages"] 186 187 menu = "# $(section["title"])\n\n$(section["description"])\n\n" 188 189 for page in pages 190 slug, title, description, order = page[1:4] 191 time = length(page) > 4 ? " ($(page[5]))" : "" 192 path = section["path"] * slug * ".md" 193 194 menu *= "- [$title]($path)$time - $description\n" 195 end 196 197 return menu 198 end 199 200 """ 201 Generate user journey menu 202 """ 203 function generate_user_journey_menu() 204 menu = "# Choose Your Path\n\n" 205 206 for (key, journey) in USER_JOURNEYS 207 title = journey["title"] 208 description = journey["description"] 209 time = journey["time"] 210 first_step = journey["path"][1] 211 212 menu *= """ 213 ## $title 214 215 $description 216 217 **Estimated time:** $time 218 219 [Start Journey]($first_step.md) 220 221 """ 222 end 223 224 return menu 225 end 226 227 """ 228 Generate breadcrumbs for a path 229 """ 230 function generate_breadcrumbs(current_path) 231 parts = split(current_path, "/") 232 filter!(p -> !isempty(p) && p != "index.md", parts) 233 234 breadcrumbs = ["[Docs](../index.md)"] 235 236 if !isempty(parts) 237 section_key = replace(parts[1], ".md" => "") 238 239 # Find section 240 for (key, section) in NAVIGATION 241 if key == section_key || section["path"] == "$(parts[1])/" 242 push!(breadcrumbs, section["title"]) 243 break 244 end 245 end 246 end 247 248 return join(breadcrumbs, " > ") 249 end 250 251 """ 252 Generate next steps for current location 253 """ 254 function generate_next_steps(section_key, page_slug) 255 if !haskey(NAVIGATION, section_key) 256 return "" 257 end 258 259 section = NAVIGATION[section_key] 260 pages = section["pages"] 261 262 # Find current page 263 current_index = 0 264 for (i, page) in enumerate(pages) 265 if page[1] == page_slug 266 current_index = i 267 break 268 end 269 end 270 271 suggestions = String[] 272 273 # Next page in section 274 if current_index > 0 && current_index < length(pages) 275 next_page = pages[current_index + 1] 276 title = next_page[2] 277 slug = next_page[1] 278 path = section["path"] * slug * ".md" 279 push!(suggestions, "- [Continue: $title]($path)") 280 end 281 282 # Next section 283 if haskey(section, "next_section") 284 next_key = section["next_section"] 285 if haskey(NAVIGATION, next_key) 286 next_section = NAVIGATION[next_key] 287 title = next_section["title"] 288 path = next_section["path"] 289 push!(suggestions, "- [Explore: $title]($path)") 290 end 291 end 292 293 return isempty(suggestions) ? "" : "## Next Steps\n\n" * join(suggestions, "\n") 294 end 295 296 # Command line interface 297 if abspath(PROGRAM_FILE) == @__FILE__ 298 if length(ARGS) == 0 299 println("Usage:") 300 println(" julia generate-nav-simple.jl menu") 301 println(" julia generate-nav-simple.jl section <section_key>") 302 println(" julia generate-nav-simple.jl journeys") 303 println(" julia generate-nav-simple.jl breadcrumbs <path>") 304 println(" julia generate-nav-simple.jl next-steps <section> <page>") 305 exit(1) 306 end 307 308 command = ARGS[1] 309 310 if command == "menu" 311 println(generate_main_menu()) 312 elseif command == "section" && length(ARGS) >= 2 313 println(generate_section_menu(ARGS[2])) 314 elseif command == "journeys" 315 println(generate_user_journey_menu()) 316 elseif command == "breadcrumbs" && length(ARGS) >= 2 317 println(generate_breadcrumbs(ARGS[2])) 318 elseif command == "next-steps" && length(ARGS) >= 3 319 println(generate_next_steps(ARGS[2], ARGS[3])) 320 else 321 println("Unknown command or missing arguments") 322 exit(1) 323 end 324 end