<?xml version="1.0"?> 

<!--
	description:

		"Eiffel Pretty-Printer"

	tool: "Gobo Eiffel Compiler"
	copyright: "Copyright (c) 2017-2019, Eric Bezault and others"
	license: "MIT License"
-->

<chapter xmlns="https://www.gobosoft.com/eiffel/gobo/documentation" id="gedoc/pretty_printer">
<chapterinfo>
	<copyright>
		<year>2017-2019</year>
		<holder>Eric Bezault</holder>
	</copyright>
	<author>
		<firstname>Eric</firstname><surname>Bezault</surname>
	</author>
	<email>ericb@gobosoft.com</email>
	<date>15 March 2019</date>
</chapterinfo>

<title>Eiffel Pretty-Printer</title>

<para>
<projectname>gedoc</projectname> can be used as an Eiffel pretty-printer. The resulting class
texts will be formatted using the same Eiffel guidelines as used throughout the Eiffel code
of the <projectname>Gobo Eiffel Project</projectname>. The Eiffel pretty-printer will generate 
valid Eiffel code. It will keep all Eiffel comments, possibly in different locations in the
class text to follow the Gobo Eiffel guidelines.
</para>
<para>
You will notice in the examples below that the command-line option 
<filename>--format</filename> is not specified. This is because 
<filename>--format=pretty_print</filename> is the default format for
<projectname>gedoc</projectname>.
</para>

<section><title>Pretty-printing a single class</title>
<para>
There are two ways to pretty-print a single class <classname>FOO</classname>:
<programlisting>
	<filename>gedoc --force foo.e</filename>
	<filename>gedoc --force --class=FOO project.ecf</filename>
</programlisting>
where <filename>foo.e</filename> is the file containing class <classname>FOO</classname>,
and <filename>project.ecf</filename> is an ECF file describing an Eiffel project containing
class <classname>FOO</classname>.
</para>
<para>
The command-line option <filename>--force</filename> tells <projectname>gedoc</projectname>
to overwrite the file containing the class being pretty-printed. Without this option,
files will not be overwritten and <projectname>gedoc</projectname> will emit an error
message. Alternatively, the command-line option <filename>--interactive</filename> can
be used. It will ask confirmation to the user before overwriting files. If you want to
generate the pretty-printed file in a directory different from the one containing the
original class text file, you should use the command-line option <filename>--output</filename>.
</para>
</section>

<section><title>Pretty-printing an Eiffel project</title>
<para>
Here is how to pretty-print all Eiffel classes in an Eiffel project:
<programlisting>
	<filename>gedoc --force project.ecf</filename>
</programlisting>
where <filename>project.ecf</filename> is an ECF file describing the Eiffel project.
You can also pretty-print a subset of classes in this Eiffel project, using the command-line 
option <filename>--class</filename> with wildcards. For example, to pretty-print only
the classes of a given Eiffel library whose names start with <classname>DS_</classname>,
just type:
<programlisting>
	<filename>gedoc --force --class=DS_* project.ecf</filename>
</programlisting>
</para>
<para>
As seen in the previous section, the command-line option <filename>--output</filename>
can be used to generate the pretty-printed files in a directory different from the
ones contaning the original class text files. The command-line option 
<filename>--library-prefix</filename> can also be used to generate the pretty-printed
files in a subfolder of this output directory whose name is the name of the Eiffel
library containing these Eiffel classes (one subfolder per library).
</para>
</section>
</chapter>
