Class: ElderDocs::Generator
- Inherits:
-
Object
- Object
- ElderDocs::Generator
- Defined in:
- lib/elder_docs/generator.rb
Defined Under Namespace
Classes: ValidationError
Instance Attribute Summary collapse
-
#api_server ⇒ Object
readonly
Returns the value of attribute api_server.
-
#articles_path ⇒ Object
readonly
Returns the value of attribute articles_path.
-
#definitions_path ⇒ Object
readonly
Returns the value of attribute definitions_path.
-
#force_build ⇒ Object
readonly
Returns the value of attribute force_build.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#skip_build ⇒ Object
readonly
Returns the value of attribute skip_build.
Instance Method Summary collapse
- #build_frontend_only! ⇒ Object
- #generate! ⇒ Object
-
#initialize(definitions_path:, articles_path:, output_path:, api_server: nil, skip_build: false, force_build: false) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(definitions_path:, articles_path:, output_path:, api_server: nil, skip_build: false, force_build: false) ⇒ Generator
Returns a new instance of Generator.
13 14 15 16 17 18 19 20 |
# File 'lib/elder_docs/generator.rb', line 13 def initialize(definitions_path:, articles_path:, output_path:, api_server: nil, skip_build: false, force_build: false) @definitions_path = definitions_path @articles_path = articles_path @output_path = File.(output_path, Dir.pwd) @api_server = api_server @skip_build = skip_build @force_build = force_build end |
Instance Attribute Details
#api_server ⇒ Object (readonly)
Returns the value of attribute api_server.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def api_server @api_server end |
#articles_path ⇒ Object (readonly)
Returns the value of attribute articles_path.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def articles_path @articles_path end |
#definitions_path ⇒ Object (readonly)
Returns the value of attribute definitions_path.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def definitions_path @definitions_path end |
#force_build ⇒ Object (readonly)
Returns the value of attribute force_build.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def force_build @force_build end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def output_path @output_path end |
#skip_build ⇒ Object (readonly)
Returns the value of attribute skip_build.
11 12 13 |
# File 'lib/elder_docs/generator.rb', line 11 def skip_build @skip_build end |
Instance Method Details
#build_frontend_only! ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/elder_docs/generator.rb', line 43 def build_frontend_only! # Build frontend without data compilation (for dynamic mode) # Check if assets already exist assets_exist = File.exist?(File.join(output_path, 'index.html')) if skip_build || (assets_exist && !force_build) say '⏭️ Skipping frontend build (assets already exist)', :yellow say '💡 Run with --force-build to rebuild', :cyan else build_frontend! copy_assets! end end |
#generate! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/elder_docs/generator.rb', line 22 def generate! validate_definitions! validate_articles! compile_data! # Check if assets already exist assets_exist = File.exist?(File.join(output_path, 'index.html')) if skip_build || (assets_exist && !force_build) say '⏭️ Skipping frontend build (assets already exist)', :yellow say '💾 Updating data.js only...', :cyan # Still update data.js with latest compiled data FileUtils.mkdir_p(output_path) File.write(File.join(output_path, 'data.js'), @compiled_data_js) say '✅ Data updated', :green else build_frontend! copy_assets! end end |