Skip to content

Commit 7612254

Browse files
committed
Add markdown provider for YARD documentation
1 parent 8ce74a4 commit 7612254

31 files changed

+1695
-1508
lines changed

.yardopts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--plugin readme
22
--markup markdown
3+
--markup-provider redcarpet
34
--output-dir docs
45

56
lib/**/*.rb

docs/Evolvable.html

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
<link rel="stylesheet" href="css/common.css" type="text/css" />
1616

17+
<link rel="stylesheet" href="css/custom.css" type="text/css" />
18+
1719
<script type="text/javascript">
1820
pathId = "Evolvable";
1921
relpath = '';
@@ -92,55 +94,60 @@
9294

9395
<h2>Overview</h2><div class="docstring">
9496
<div class="discussion">
95-
<p>The evolutionary process works through these components:
96-
1. <strong>Populations</strong>: Groups of the “evolvable” instances you define
97-
2. <strong>Genes</strong>: Ruby objects that cache data for evolvables
98-
3. <strong>Evaluation</strong>: Sorts evolvables by fitness
99-
4. <strong>Evolution</strong>: Selection, combination, and mutation to generate new evolvables</p>
100-
101-
<p>Quick start:
102-
1. Include <code>Evolvable</code> in your Ruby class
103-
2. Define genes with the macro-style <code>gene</code> method
104-
3. Have the <code>#fitness</code> method return a numeric value
105-
4. Initialize a population and evolve it</p>
106-
107-
<p>Example population of “shirts” with various colors, buttons, and collars.</p>
108-
109-
<p>```ruby
110-
# Step 1
111-
class Shirt
112-
include Evolvable</p>
113-
114-
<pre class="code ruby"><code class="ruby"># Step 2
115-
gene :color, type: ColorGene # count: 1 default
116-
gene :buttons, type: ButtonGene, count: 0..10 # Builds an array of genes that can vary in size
117-
gene :collar, type: CollarGene, count: 0..1 # Collar optional
118-
119-
# Step 3
120-
attr_accessor :fitness end
97+
<p>The evolutionary process works through these components:</p>
98+
99+
<ol>
100+
<li><strong>Populations</strong>: Groups of the &quot;evolvable&quot; instances you define</li>
101+
<li><strong>Genes</strong>: Ruby objects that cache data for evolvables</li>
102+
<li><strong>Evaluation</strong>: Sorts evolvables by fitness</li>
103+
<li><strong>Evolution</strong>: Selection, combination, and mutation to generate new evolvables</li>
104+
</ol>
105+
106+
<p>Quick start:</p>
107+
108+
<ol>
109+
<li>Include <code>Evolvable</code> in your Ruby class</li>
110+
<li>Define genes with the macro-style <code>gene</code> method</li>
111+
<li>Have the <code>#fitness</code> method return a numeric value</li>
112+
<li>Initialize a population and evolve it</li>
113+
</ol>
114+
115+
<p>Example population of &quot;shirts&quot; with various colors, buttons, and collars.</p>
116+
117+
<pre class="code ruby"><code class="ruby"> <span class='comment'># Step 1
118+
</span> <span class='kw'>class</span> <span class='const'>Shirt</span>
119+
<span class='id identifier rubyid_include'>include</span> <span class='const'>Evolvable</span>
120+
121+
<span class='comment'># Step 2
122+
</span> <span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:color</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>ColorGene</span> <span class='comment'># count: 1 default
123+
</span> <span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:buttons</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>ButtonGene</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>0</span><span class='op'>..</span><span class='int'>10</span> <span class='comment'># Builds an array of genes that can vary in size
124+
</span> <span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:collar</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>CollarGene</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>0</span><span class='op'>..</span><span class='int'>1</span> <span class='comment'># Collar optional
125+
</span>
126+
<span class='comment'># Step 3
127+
</span> <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:fitness</span>
128+
<span class='kw'>end</span>
129+
130+
<span class='comment'># Step 4
131+
</span> <span class='id identifier rubyid_population'>population</span> <span class='op'>=</span> <span class='const'>Shirt</span><span class='period'>.</span><span class='id identifier rubyid_new_population'>new_population</span><span class='lparen'>(</span><span class='label'>size:</span> <span class='int'>10</span><span class='rparen'>)</span>
132+
<span class='id identifier rubyid_population'>population</span><span class='period'>.</span><span class='id identifier rubyid_evolvables'>evolvables</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_shirt'>shirt</span><span class='op'>|</span> <span class='id identifier rubyid_shirt'>shirt</span><span class='period'>.</span><span class='id identifier rubyid_fitness'>fitness</span> <span class='op'>=</span> <span class='id identifier rubyid_tried_it_on_score'>tried_it_on_score</span> <span class='rbrace'>}</span>
121133
</code></pre>
122134

123-
<p># Step 4
124-
population = Shirt.new_population(size: 10)
125-
population.evolvables.each { |shirt| shirt.fitness = tried_it_on_score }
126-
```</p>
127-
128-
<p>You are free to tailor the genes to your needs and “try it on” yourself.</p>
135+
<p>You are free to tailor the genes to your needs and &quot;try it on&quot; yourself.</p>
129136

130137
<p>The <code>ColorGene</code> could be as simple as this:</p>
131138

132-
<p>```ruby
133-
class ColorGene
134-
include Evolvable::Gene</p>
139+
<pre class="code ruby"><code class="ruby"> <span class='kw'>class</span> <span class='const'>ColorGene</span>
140+
<span class='id identifier rubyid_include'>include</span> <span class='const'>Evolvable</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Evolvable/Gene.html" title="Evolvable::Gene (module)">Gene</a></span></span>
135141

136-
<pre class="code ruby"><code class="ruby">def to_s
137-
@to_s ||= %w[red green blue].sample
138-
end end ```
142+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
143+
<span class='ivar'>@to_s</span> <span class='op'>||=</span> <span class='qwords_beg'>%w[</span><span class='tstring_content'>red</span><span class='words_sep'> </span><span class='tstring_content'>green</span><span class='words_sep'> </span><span class='tstring_content'>blue</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span>
144+
<span class='kw'>end</span>
145+
<span class='kw'>end</span>
139146
</code></pre>
140147

141148
<p>Not into shirts?</p>
142149

143-
<p>Heres a <a href="https://github.com/mattruzicka/evolvable/blob/main/exe/hello_evolvable_world">Hello World</a> command line demo.</p>
150+
<p>Here&#39;s a <a href="https://github.com/mattruzicka/evolvable/blob/main/exe/hello_evolvable_world">Hello World</a> command line demo.</p>
144151

145152

146153
</div>
@@ -348,8 +355,7 @@ <h2>
348355

349356

350357

351-
<span class="summary_desc"><div class='inline'>
352-
</div></span>
358+
<span class="summary_desc"><div class='inline'></div></span>
353359

354360
</li>
355361

@@ -394,8 +400,7 @@ <h2>
394400

395401

396402

397-
<span class="summary_desc"><div class='inline'>
398-
</div></span>
403+
<span class="summary_desc"><div class='inline'></div></span>
399404

400405
</li>
401406

@@ -440,8 +445,7 @@ <h2>
440445

441446

442447

443-
<span class="summary_desc"><div class='inline'>
444-
</div></span>
448+
<span class="summary_desc"><div class='inline'></div></span>
445449

446450
</li>
447451

@@ -463,8 +467,7 @@ <h2>
463467

464468

465469

466-
<span class="summary_desc"><div class='inline'>
467-
</div></span>
470+
<span class="summary_desc"><div class='inline'></div></span>
468471

469472
</li>
470473

@@ -555,7 +558,7 @@ <h2>
555558

556559

557560

558-
<span class="summary_desc"><div class='inline'><p>Merges another genome into this evolvables genome.</p>
561+
<span class="summary_desc"><div class='inline'><p>Merges another genome into this evolvable&#39;s genome.</p>
559562
</div></span>
560563

561564
</li>
@@ -1486,7 +1489,7 @@ <h3 class="signature " id="merge_genome!-instance_method">
14861489

14871490
</h3><div class="docstring">
14881491
<div class="discussion">
1489-
<p>Merges another genome into this evolvables genome.
1492+
<p>Merges another genome into this evolvable&#39;s genome.
14901493
Useful for combining genetic traits from different evolvables.</p>
14911494

14921495

@@ -1557,7 +1560,7 @@ <h3 class="signature " id="merge_genome!-instance_method">
15571560
</div>
15581561

15591562
<div id="footer">
1560-
Generated on Thu May 8 23:57:27 2025 by
1563+
Generated on Fri May 9 00:09:34 2025 by
15611564
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
15621565
0.9.37 (ruby-3.4.2).
15631566
</div>

docs/Evolvable/ClassMethods.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
<link rel="stylesheet" href="../css/common.css" type="text/css" />
1616

17+
<link rel="stylesheet" href="../css/custom.css" type="text/css" />
18+
1719
<script type="text/javascript">
1820
pathId = "Evolvable::ClassMethods";
1921
relpath = '../';
@@ -625,11 +627,14 @@ <h3 class="signature " id="cluster-instance_method">
625627
<div class="discussion">
626628
<p>The <code>.cluster</code> macro applies a pre-defined group of related genes.</p>
627629

628-
<p>Clusters promote code organization through:
629-
- Modularity: Define related genes once, reuse them
630-
- Organization: Group genes by function
631-
- Maintenance: Update in one place
632-
- Accessibility: Access via a single accessor</p>
630+
<p>Clusters promote code organization through:</p>
631+
632+
<ul>
633+
<li>Modularity: Define related genes once, reuse them</li>
634+
<li>Organization: Group genes by function</li>
635+
<li>Maintenance: Update in one place</li>
636+
<li>Accessibility: Access via a single accessor</li>
637+
</ul>
633638

634639

635640
</div>
@@ -766,10 +771,13 @@ <h3 class="signature " id="gene-instance_method">
766771
<p>The <code>.gene</code> macro defines traits that can mutate and evolve over time.
767772
Syntactically similar to ActiveRecord-style macros, it sets up the genetic structure of your model.</p>
768773

769-
<p>Key features:
770-
- Fixed or variable gene counts
771-
- Automatic accessor methods
772-
- Optional clustering for related genes</p>
774+
<p>Key features:</p>
775+
776+
<ul>
777+
<li>Fixed or variable gene counts</li>
778+
<li>Automatic accessor methods</li>
779+
<li>Optional clustering for related genes</li>
780+
</ul>
773781

774782

775783
</div>
@@ -1070,12 +1078,12 @@ <h3 class="signature " id="new_evolvable-instance_method">
10701078
</h3><div class="docstring">
10711079
<div class="discussion">
10721080
<p>Initializes a new instance. Accepts a population object, an array of gene objects,
1073-
and the instances population index. This method is useful for re-initializing
1081+
and the instance&#39;s population index. This method is useful for re-initializing
10741082
instances and populations that have been saved.</p>
10751083

10761084
<p><em>It is not recommended that you override this method</em> as it is used by
10771085
Evolvable internals. If you need to customize how your instances are
1078-
initialized you can override either of the following two initialize_instance
1086+
initialized you can override either of the following two &quot;initialize_instance&quot;
10791087
methods.</p>
10801088

10811089

@@ -1217,7 +1225,7 @@ <h3 class="signature " id="new_population-instance_method">
12171225
</div>
12181226

12191227
<div id="footer">
1220-
Generated on Thu May 8 23:57:27 2025 by
1228+
Generated on Fri May 9 00:09:34 2025 by
12211229
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
12221230
0.9.37 (ruby-3.4.2).
12231231
</div>

docs/Evolvable/Community.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
<link rel="stylesheet" href="../css/common.css" type="text/css" />
1616

17+
<link rel="stylesheet" href="../css/custom.css" type="text/css" />
18+
1719
<script type="text/javascript">
1820
pathId = "Evolvable::Community";
1921
relpath = '../';
@@ -93,18 +95,18 @@ <h2>Overview</h2><div class="docstring">
9395
<p><strong>Key Features</strong></p>
9496

9597
<ul>
96-
<li>Define a community with multiple population types</li>
97-
<li>Manage relationships between different evolvable types</li>
98-
<li>Coordinate evolution across multiple populations</li>
99-
<li>Access populations and instances through a unified interface</li>
98+
<li>Define a community with multiple population types</li>
99+
<li>Manage relationships between different evolvable types</li>
100+
<li>Coordinate evolution across multiple populations</li>
101+
<li>Access populations and instances through a unified interface</li>
100102
</ul>
101103

102104
<p><strong>Example Use Cases</strong></p>
103105

104106
<ul>
105-
<li><strong>Ecosystems</strong>: Simulate interactions between plants, herbivores, and predators</li>
106-
<li><strong>Multi-component Systems</strong>: Design systems where components evolve together</li>
107-
<li><strong>Layered Optimization</strong>: Solve problems with different optimization levels</li>
107+
<li><strong>Ecosystems</strong>: Simulate interactions between plants, herbivores, and predators</li>
108+
<li><strong>Multi-component Systems</strong>: Design systems where components evolve together</li>
109+
<li><strong>Layered Optimization</strong>: Solve problems with different optimization levels</li>
108110
</ul>
109111

110112

@@ -176,8 +178,7 @@ <h2>
176178

177179

178180

179-
<span class="summary_desc"><div class='inline'>
180-
</div></span>
181+
<span class="summary_desc"><div class='inline'></div></span>
181182

182183
</li>
183184

@@ -1185,7 +1186,7 @@ <h3 class="signature " id="reset_populations-instance_method">
11851186
</div>
11861187

11871188
<div id="footer">
1188-
Generated on Thu May 8 23:57:27 2025 by
1189+
Generated on Fri May 9 00:09:35 2025 by
11891190
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
11901191
0.9.37 (ruby-3.4.2).
11911192
</div>

docs/Evolvable/Community/ClassMethods.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
1616

17+
<link rel="stylesheet" href="../../css/custom.css" type="text/css" />
18+
1719
<script type="text/javascript">
1820
pathId = "Evolvable::Community::ClassMethods";
1921
relpath = '../../';
@@ -215,8 +217,7 @@ <h2>
215217

216218

217219

218-
<span class="summary_desc"><div class='inline'>
219-
</div></span>
220+
<span class="summary_desc"><div class='inline'></div></span>
220221

221222
</li>
222223

@@ -699,7 +700,7 @@ <h3 class="signature " id="populations_by_name-instance_method">
699700
</div>
700701

701702
<div id="footer">
702-
Generated on Thu May 8 23:57:27 2025 by
703+
Generated on Fri May 9 00:09:35 2025 by
703704
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
704705
0.9.37 (ruby-3.4.2).
705706
</div>

docs/Evolvable/CountGene.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
<link rel="stylesheet" href="../css/common.css" type="text/css" />
1616

17+
<link rel="stylesheet" href="../css/custom.css" type="text/css" />
18+
1719
<script type="text/javascript">
1820
pathId = "Evolvable::CountGene";
1921
relpath = '../';
@@ -151,8 +153,8 @@ <h2>
151153
These lambdas determine how two count genes are merged during evolution.</p>
152154

153155
<ol>
154-
<li>Random selection with slight mutation (-1, 0, or +1)</li>
155-
<li>Average of the two counts</li>
156+
<li>Random selection with slight mutation (-1, 0, or +1)</li>
157+
<li>Average of the two counts</li>
156158
</ol>
157159

158160

@@ -874,7 +876,7 @@ <h3 class="signature " id="min_count-instance_method">
874876
</div>
875877

876878
<div id="footer">
877-
Generated on Thu May 8 23:57:27 2025 by
879+
Generated on Fri May 9 00:09:35 2025 by
878880
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
879881
0.9.37 (ruby-3.4.2).
880882
</div>

0 commit comments

Comments
 (0)