Page MenuHomePhabricator

mono-docs: Allow embedding external examples
ClosedPublic

Authored by segfaultxavi on Apr 10 2019, 11:05 AM.

Details

Summary

New option added to eolian_gen: -e <dir>
This specifies a directory to search for examples. If a file is found with the
same name as an EFL C# class (e.g. Efl.Ui.Button.cs) or as an EFL C# method or
property (e.g. Efl.IText.Text.cs, Efl.IText.SetText.cs) its full
contents will be embedded in the documentation for that class or method within
<example> and <code> tags. This is, in turn, is parsed by DocFX and shown
in Example boxes in the generated pages.
If an example file is not found, no examples are embedded for that object.
If -e is not used, no examples are embedded for any object.

New option added to meson: mono-examples-dir to point to the examples directory.
This directory is then passed to eolian_mono through -e.
Do not use it (or define it to nothing) to disable example embedding.

No performance drop has been observed because of these extra tests.

Right now examples can only be given for base classes, not for derived ones
(i.e. Efl.IText.Text but not Efl.Ui.Button.Text). This will be addressed in a
later commit.

Feature
Depends on D8587

Test Plan

Create an examples folder and put some files in it:

mkdir /tmp/examples
echo 'var button = new Efl.Ui.Button();' > /tmp/examples/Efl.Ui.Button.cs
echo 'button.AutoRepeatEnabled = true;' > /tmp/examples/Efl.Ui.IAutorepeat.AutorepeatEnabled.cs
echo 'button.SetAutoRepeatEnabled(true);' > /tmp/examples/Efl.Ui.IAutorepeat.SetAutorepeatEnabled.cs

Configure meson to embed examples and build:

meson configure -Dmono-examples-dir=/tmp/examples
ninja

Examine the generated efl_ui_button.eo.cs file to see embedded <example> tags,
or run DocFX and bask in the glory of documentation pages with examples:

cd doc/docfx
./gendoc.sh

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
segfaultxavi created this revision.Apr 10 2019, 11:05 AM
segfaultxavi requested review of this revision.Apr 10 2019, 11:05 AM
segfaultxavi edited the test plan for this revision. (Show Details)Apr 10 2019, 11:08 AM

I wanted to use Text for demo, but it is a bad example because it is blacklisted (T7791 should take care of that).

Rebase after changes in parent commit

vitor.sousa accepted this revision.Apr 10 2019, 1:41 PM

Awesome.

This revision is now accepted and ready to land.Apr 10 2019, 1:41 PM
This revision was automatically updated to reflect the committed changes.