Blame programming-guidelines/es/documentation.page

Packit 1470ea
Packit 1470ea
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2003/XInclude" type="topic" id="documentation" xml:lang="es">
Packit 1470ea
Packit 1470ea
  <info>
Packit 1470ea
    <link type="guide" xref="index#general-guidelines"/>
Packit 1470ea
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Federico Mena-Quintero</name>
Packit 1470ea
      <email its:translate="no">federico@gnome.org</email>
Packit 1470ea
      <years>2013</years>
Packit 1470ea
    </credit>
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Philip Withnall</name>
Packit 1470ea
      <email its:translate="no">philip.withnall@collabora.co.uk</email>
Packit 1470ea
      <years>2015</years>
Packit 1470ea
    </credit>
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>El equipo de GTK+</name>
Packit 1470ea
    </credit>
Packit 1470ea
Packit 1470ea
    <include xmlns="http://www.w3.org/2001/XInclude" href="cc-by-sa-3-0.xml"/>
Packit 1470ea
Packit 1470ea
    <desc>Añadir documentación para bibliotecas y API</desc>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Daniel Mustieles</mal:name>
Packit 1470ea
      <mal:email>daniel.mustieles@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2016</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Javier Mazorra</mal:name>
Packit 1470ea
      <mal:email>mazi.debian@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2016</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  </info>
Packit 1470ea
Packit 1470ea
  <title>Documentación</title>
Packit 1470ea
Packit 1470ea
  <synopsis>
Packit 1470ea
    <title>Resumen</title>
Packit 1470ea
Packit 1470ea
    <list>
Packit 1470ea
      <item>

Use gtk-doc con una configuración actualizada para la documentación de la API. (Consulte la <link xref="#gtk-doc"/>)

</item>
Packit 1470ea
      <item>

Packit 1470ea
        Use XML entities for including external symbols into the documentation.
Packit 1470ea
        (<link xref="#build-system"/>)
Packit 1470ea
      

</item>
Packit 1470ea
      <item>

Packit 1470ea
        Use a consistent, standard, table of contents for all API documentation
Packit 1470ea
        to maintain familiarity. (<link xref="#standard-layout"/>)
Packit 1470ea
      

</item>
Packit 1470ea
      <item>

Use <cmd>gdbus-codegen</cmd> para generar la documentación de la API de D-Bus que incluir en la construcción de gtk-doc. (Consulte la <link xref="#dbus-api"/>)

</item>
Packit 1470ea
      <item>

Añada anotaciones de instrospección a toda la documentación de la API. (Consulte la <link xref="#introspection-annotations"/>)

</item>
Packit 1470ea
      <item>

Packit 1470ea
        Add Since lines to all API documentation.
Packit 1470ea
        (<link xref="#symbol-versioning"/>)
Packit 1470ea
      

</item>
Packit 1470ea
      <item>

Activar las pruebas de gtk-doc. (<link xref="#keeping-up-to-date"/>)

</item>
Packit 1470ea
    </list>
Packit 1470ea
  </synopsis>
Packit 1470ea
Packit 1470ea
  <section id="gtk-doc">
Packit 1470ea
    <title>gtk-doc</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      The preferred documentation system for GNOME libraries is <link href="http://www.gtk.org/gtk-doc/">gtk-doc</link>, which
Packit 1470ea
      extracts inline comments from the code to let you build a <link href="http://docbook.org/">DocBook</link> document and collection of HTML
Packit 1470ea
      pages.  These can then be read in
Packit 1470ea
      <link href="https://wiki.gnome.org/Apps/Devhelp">Devhelp</link>.  A lot of
Packit 1470ea
      GNOME’s infrastructure is built to handle with documentation written using
Packit 1470ea
      gtk-doc.
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="build-system">
Packit 1470ea
    <title>Sistema de construcción</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      To integrate gtk-doc into a project’s build system, follow the
Packit 1470ea
      <link href="https://developer.gnome.org/gtk-doc-manual/stable/settingup.html.en">
Packit 1470ea
      instructions in the gtk-doc manual</link>. Note that while the
Packit 1470ea
      <file>sections.txt</file> file is automatically generated the first time
Packit 1470ea
      gtk-doc is run, it is not generated subsequently, and should be kept up to
Packit 1470ea
      date manually. It should also be
Packit 1470ea
      <link href="https://developer.gnome.org/gtk-doc-manual/stable/settingup_vcs.html.en">
Packit 1470ea
      in version control</link>.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      gtk-doc’s no-tmpl flavour should be used, and XML mode should
Packit 1470ea
      be used instead of SGML. (tmpl mode and SGML are both outdated and slower
Packit 1470ea
      than XML.)
Packit 1470ea
    

Packit 1470ea
    

Packit 1470ea
      If the package version is needed to be substituted into the documentation,
Packit 1470ea
      create a file named <file>docs/version.xml.in</file>, containing:
Packit 1470ea
    

Packit 1470ea
    @PACKAGE_VERSION@
Packit 1470ea
    

Packit 1470ea
      Add it to AC_CONFIG_FILES in <file>configure.ac</file>, then
Packit 1470ea
      include it into the main documentation file (<file>*-docs.xml</file>)
Packit 1470ea
      using: <!ENTITY version SYSTEM "version.xml"> in the
Packit 1470ea
      DOCTYPE at the top of the document. The package version can
Packit 1470ea
      then be used inline as &version;.
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="standard-layout">
Packit 1470ea
    <title>Distribución estándar</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Using a standard layout for the table of contents, sections, appendices,
Packit 1470ea
      etc. means the same <file>project-name-docs.xml</file> template
Packit 1470ea
      can be reused with few changes between projects. It also means the
Packit 1470ea
      documentation layout is similar across all projects, making it more
Packit 1470ea
      familiar to developers.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Se sugiere la siguiente distribución:

Packit 1470ea
    <listing>
Packit 1470ea
      <title><file>nombre-proyecto-docs.xml</file></title>
Packit 1470ea
      <desc>A template top-level gtk-doc file for a project</desc>
Packit 1470ea
      <xi:include href="example-docs.xml" parse="text"/>
Packit 1470ea
    </listing>
Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="licensing">
Packit 1470ea
    <title>Licencia</title>
Packit 1470ea
    

Packit 1470ea
      It is important to make the license used for API references clear,
Packit 1470ea
      especially if they contain code examples which could be copied around.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Typically, projects use the same license for their API reference as for 
Packit 1470ea
      the project’s code itself, to avoid confusion. Some other projects use
Packit 1470ea
      CC-BY-SA 3.0 for all their reference documentation. The choice is yours.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      As shown in the <link xref="#standard-layout">Standard Layout</link> you
Packit 1470ea
      should include a <file>license.xml</file> in the top-level gtk-doc DocBook
Packit 1470ea
      file which gives the full text of your documentation license.
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="public-api">
Packit 1470ea
    <title>API públicas</title>
Packit 1470ea
Packit 1470ea
    

Todas las API públicas deben tener comentarios de tipo gtk-doc. Para las funciones, estos se deben colocar en el código fuente, encima de la función.

Packit 1470ea
Packit 1470ea
    /**
Packit 1470ea
 * gtk_get_flow:
Packit 1470ea
 * @widget: a #GtkWidget
Packit 1470ea
 *
Packit 1470ea
 * Gets the flow of a widget.
Packit 1470ea
 *
Packit 1470ea
 * Note that flows may be laminar or turbulent...
Packit 1470ea
 *
Packit 1470ea
 * Returns: (transfer none): the flow of @widget
Packit 1470ea
 */
Packit 1470ea
GtkFlow *
Packit 1470ea
gtk_get_flow (GtkWidget *widget)
Packit 1470ea
{
Packit 1470ea
Packit 1470ea
  ...
Packit 1470ea
Packit 1470ea
}
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Documentation comments for macros, function types, class
Packit 1470ea
      structs, etc. should be placed next to the definitions, typically
Packit 1470ea
      in header files.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Section introductions should be placed in the source file they describe,
Packit 1470ea
      after the license header:
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    /**
Packit 1470ea
 * SECTION:gtksizerequest
Packit 1470ea
 * @Short_Description: Height-for-width geometry management
Packit 1470ea
 * @Title: GtkSizeRequest
Packit 1470ea
 *
Packit 1470ea
 * The GtkSizeRequest interface is GTK+'s height-for-width (and
Packit 1470ea
 * width-for-height) geometry management system.
Packit 1470ea
 * ...
Packit 1470ea
 */
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Keep in mind that in order to include a function, macro,
Packit 1470ea
      function type, or struct type, it needs to be listed in your
Packit 1470ea
      documentation’s <file>modulename-sections.txt</file> file.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      To properly document a new class, it needs to be given its own
Packit 1470ea
      section in <file>modulename-sections.txt</file>, needs to be
Packit 1470ea
      included in your toplevel <file>modulename-docs.sgml</file>,
Packit 1470ea
      and the get_type() function for your class needs
Packit 1470ea
      to be listed in your <file>modulename.types</file>.
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="introspection-annotations">
Packit 1470ea
    <title>Anotaciones de instrospección</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Each gtk-doc comment should have appropriate
Packit 1470ea
      <link href="https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations">
Packit 1470ea
      GObject introspection annotations</link>. These are useful for two
Packit 1470ea
      reasons:
Packit 1470ea
    

Packit 1470ea
    <list type="numbered">
Packit 1470ea
      <item>

Packit 1470ea
        They add important information about parameter types, nullability and
Packit 1470ea
        memory management to the C API documentation generated by gtk-doc.
Packit 1470ea
      

</item>
Packit 1470ea
      <item>

Packit 1470ea
        They allow public APIs to be automatically bound in other languages,
Packit 1470ea
        such as Python or JavaScript.
Packit 1470ea
      

</item>
Packit 1470ea
    </list>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Introspection annotations add information to APIs (functions, function
Packit 1470ea
      parameters, function return values, structures, GObject properties,
Packit 1470ea
      GObject signals) which is otherwise not present in the machine readable C
Packit 1470ea
      API and only exists in the form of human readable documentation or
Packit 1470ea
      convention. They are very important.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      In gtk-doc comments, annotations should be preferred over human-readable
Packit 1470ea
      equivalents. For example, when documenting a function parameter which may
Packit 1470ea
      be NULL, use the (nullable) annotation rather
Packit 1470ea
      than some text:
Packit 1470ea
    

Packit 1470ea
    /**
Packit 1470ea
 * my_function:
Packit 1470ea
 * @parameter: (nullable): some parameter which affects something
Packit 1470ea
 *
Packit 1470ea
 * Body of the function documentation.
Packit 1470ea
 */
Packit 1470ea
Packit 1470ea
    

En lugar de:

Packit 1470ea
    /**
Packit 1470ea
 * my_bad_function:
Packit 1470ea
 * @parameter: some parameter which affects something, or %NULL to ignore
Packit 1470ea
 *
Packit 1470ea
 * Bad body of the function documentation.
Packit 1470ea
 */
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      For more information on introspection, see the
Packit 1470ea
      <link xref="introspection">introspection guidelines</link>.
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="symbol-versioning">
Packit 1470ea
    <title>Versionado de símbolos</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      Whenever a symbol is added to the public API, it should have a
Packit 1470ea
      documentation comment added. This comment should always contain a
Packit 1470ea
      Since line with the package version number of the release
Packit 1470ea
      which will first contain the new API. This should be the number currently
Packit 1470ea
      in <file>configure.ac</file> if
Packit 1470ea
      <link xref="versioning#release-process">post-release version
Packit 1470ea
      incrementing</link> is being used.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Por ejemplo:

Packit 1470ea
    /**
Packit 1470ea
 * my_function:
Packit 1470ea
 * @param: some parameter
Packit 1470ea
 *
Packit 1470ea
 * Body of the function documentation.
Packit 1470ea
 *
Packit 1470ea
 * Since: 0.5.0
Packit 1470ea
 */
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      gtk-doc uses this information to generate indexes of the APIs added in
Packit 1470ea
      each release. These should be added to the main <file>*-docs.xml</file> as
Packit 1470ea
      an appendix:
Packit 1470ea
    

Packit 1470ea
    <part>
Packit 1470ea
	<title>Appendices</title>
Packit 1470ea
	<index id="api-index-full">
Packit 1470ea
		<title>API Index</title>
Packit 1470ea
		<xi:include href="xml/api-index-full.xml"><xi:fallback/></xi:include>
Packit 1470ea
	</index>
Packit 1470ea
	<index id="api-index-deprecated">
Packit 1470ea
		<title>Index of deprecated symbols</title>
Packit 1470ea
		<xi:include href="xml/api-index-deprecated.xml"><xi:fallback/></xi:include>
Packit 1470ea
	</index>
Packit 1470ea
	<index role="0.1.0">
Packit 1470ea
		<title>Index of new symbols in 0.1.0</title>
Packit 1470ea
		<xi:include href="xml/api-index-0.1.0.xml"><xi:fallback/></xi:include>
Packit 1470ea
	</index>
Packit 1470ea
	<!-- More versions here. -->
Packit 1470ea
	<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
Packit 1470ea
</part>
Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="dbus-api">
Packit 1470ea
    <title>API de D-Bus</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      D-Bus interface descriptions contain documentation comments, and these can
Packit 1470ea
      be extracted from the XML using <cmd>gdbus-codegen</cmd>, and turned into
Packit 1470ea
      DocBook files to be included by gtk-doc.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      The DocBook files can be included in the main <file>*-docs.xml</file> file
Packit 1470ea
      using:
Packit 1470ea
    

Packit 1470ea
    <chapter>
Packit 1470ea
  <title>C Interfaces</title>
Packit 1470ea
  <partintro>
Packit 1470ea
    <para>C wrappers for the D-Bus interfaces.</para>
Packit 1470ea
  </partintro>
Packit 1470ea
Packit 1470ea
  <xi:include href="xml/SomeDBusService.xml"/>
Packit 1470ea
  <xi:include href="xml/SomeOtherService.xml"/>
Packit 1470ea
</chapter>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      The generated XML files must be included in the content_files
Packit 1470ea
      variable in your gtk-doc <file>Makefile.am</file>, otherwise the build
Packit 1470ea
      will fail. (This is to fix situations where the builddir does
Packit 1470ea
      not equal the srcdir.)
Packit 1470ea
    

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="keeping-up-to-date">
Packit 1470ea
    <title>Mantener la documentación actualizada</title>
Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      gtk-doc comes with support for checking the documentation with some basic
Packit 1470ea
      tests. These check that all version indexes are included in the main
Packit 1470ea
      <file>*-docs.xml</file> file and that all symbols are documented, among
Packit 1470ea
      other things.
Packit 1470ea
    

Packit 1470ea
Packit 1470ea
    

Packit 1470ea
      These tests should always be enabled, by adding the following to your
Packit 1470ea
      gtk-doc <file>Makefile.am</file>:
Packit 1470ea
    

Packit 1470ea
    TESTS = $(GTKDOC_CHECK)
Packit 1470ea
Packit 1470ea
    

Se ejecutarán como parte de <cmd>make check</cmd>.

Packit 1470ea
  </section>
Packit 1470ea
</page>