]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 963120 - allow extensions to document themselves, and build result into docs...
authorGervase Markham <gerv@gerv.net>
Tue, 25 Feb 2014 12:00:48 +0000 (12:00 +0000)
committerGervase Markham <gerv@mozilla.org>
Tue, 25 Feb 2014 12:00:48 +0000 (12:00 +0000)
docs/en/rst/extensions.rst [new file with mode: 0644]
docs/en/rst/index.rst
docs/makedocs.pl
extensions/Example/doc/example.rst [new file with mode: 0644]
extensions/create.pl
t/008filter.t
template/en/default/extensions/name.rst.tmpl [new file with mode: 0644]

diff --git a/docs/en/rst/extensions.rst b/docs/en/rst/extensions.rst
new file mode 100644 (file)
index 0000000..91eaab9
--- /dev/null
@@ -0,0 +1,11 @@
+Extensions
+==========
+
+Your Bugzilla installation has the following extensions available (as of the
+last time you compiled the documentation):
+
+.. toctree::
+   :maxdepth: 1
+   :glob:
+   
+   extensions/*
index abb63d0eeadba7825dd8dd55f63dcb06618931da..f2bd14f18b0f7ba986636d78b120b8d494a8b2af 100644 (file)
@@ -15,8 +15,9 @@ Bugzilla Documentation
    administration
    security
    using
+   extensions
    customization
-   troubleshooting
    patches
+   troubleshooting
    modules
    gfdl
index deb117ff3f9ccc85ca356b15f0e952ce3015ae61..d14e79434bcbf98487822b774520c7294f52d259 100755 (executable)
@@ -25,6 +25,8 @@ use 5.10.1;
 use strict;
 
 use Cwd;
+use File::Find;
+use File::Copy;
 
 # We need to be in this directory to use our libraries.
 BEGIN {
@@ -122,6 +124,24 @@ foreach my $lang (@langs) {
 
     next if grep { $_ eq '--pod-only' } @ARGV;
 
+    # Collect up local extension documentation into the extensions/ dir.
+    sub wanted {
+        if ($File::Find::dir =~ /\/doc\/?$/ &&
+            $_ =~ /\.rst$/)
+        {
+            copy($File::Find::name, "rst/extensions");
+        }
+    };
+
+    # Clear out old extensions docs
+    rmtree('rst/extensions', 0, 1);
+    mkdir('rst/extensions');
+    
+    find({
+        'wanted' => \&wanted,
+        'no_chdir' => 1,
+    }, "$docparent/../extensions");
+
     MakeDocs('HTML', 'make html');
     MakeDocs('TXT', 'make text');
 
diff --git a/extensions/Example/doc/example.rst b/extensions/Example/doc/example.rst
new file mode 100644 (file)
index 0000000..07b3558
--- /dev/null
@@ -0,0 +1,22 @@
+Example
+#######
+
+This is a sample documentation file for the Example extension. Like all of
+the Bugzilla docs, it's written in
+`reStructured Text (reST) format <http://sphinx-doc.org/latest/rest.html>`_
+and will be compiled by `Sphinx <http://sphinx-doc.org/>`_.
+
+If you build the docs yourself using :file:`makedocs.pl`, this file will get
+incorporated into the Extensions chapter, as will any documentation
+you write for your extensions which fulfils the following criteria:
+
+* In the :file:`extensions/YourExtension/doc/` directory
+* Has a :file:`.rst` file extension
+
+You are recommended to make the name of your reST doc file the same as the
+name of your extension, so that there is no clash when all the extension
+documentation is copied into the same directory. So, for example, this file
+is called :file:`example.rst`, as it's part of the Example extension. If you
+need multiple documentation files, prefix the filename with the name of your
+extension, e.g. :file:`example-extra.rst`.
index e5a436845c6e467c4f54e1b4ecf91bbb042df812..e2d3321b195ae85d14b8652fabf0bcbb8b05b01e 100755 (executable)
@@ -30,7 +30,7 @@ mkpath($extension_dir)
   || die "$extension_dir already exists or cannot be created.\n";
 
 my $lcname = lc($name);
-foreach my $path (qw(lib web template/en/default/hook), 
+foreach my $path (qw(lib doc web template/en/default/hook), 
                   "template/en/default/$lcname")
 {
     mkpath("$extension_dir/$path") || die "$extension_dir/$path: $!";
@@ -45,6 +45,7 @@ my %create_files = (
     'web-readme.txt.tmpl'  => 'web/README',
     'hook-readme.txt.tmpl' => 'template/en/default/hook/README',
     'name-readme.txt.tmpl' => "template/en/default/$lcname/README",
+    'name.rst.tmpl'        => "doc/$lcname.rst",
 );
 
 foreach my $template_file (keys %create_files) {
index 4977658bbb1d606ac01404a6ffa8cfb10a09e56f..9551ae2b246b2e72182eb001c5c4d5ad9301913a 100644 (file)
@@ -80,7 +80,7 @@ foreach my $path (@Support::Templates::include_paths) {
     foreach my $file (@testitems) {
         # There are some files we don't check, because there is no need to
         # filter their contents due to their content-type.
-        if ($file =~ /\.(pm|txt|png)\.tmpl$/) {
+        if ($file =~ /\.(pm|txt|rst|png)\.tmpl$/) {
             ok(1, "($lang/$flavor) $file is filter-safe");
             next;
         }
diff --git a/template/en/default/extensions/name.rst.tmpl b/template/en/default/extensions/name.rst.tmpl
new file mode 100644 (file)
index 0000000..c2e1b5a
--- /dev/null
@@ -0,0 +1,23 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+  # License, v. 2.0. If a copy of the MPL was not distributed with this
+  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  #
+  # This Source Code Form is "Incompatible With Secondary Licenses", as
+  # defined by the Mozilla Public License, v. 2.0.
+  #%]
+
+[%# INTERFACE:
+  # name: string; the name of the extension.
+  #%]
+
+[% USE String('#') %]
+[% name %]
+[%+ String.repeat(name.length) %]
+
+This is a sample documentation file for the [% name %] extension. Like all of
+the Bugzilla docs, it's written in
+`reStructured Text (reST) format <http://sphinx-doc.org/latest/rest.html>`_
+and will be compiled by `Sphinx <http://sphinx-doc.org/>`_.
+
+If you build the docs yourself using :file:`makedocs.pl`, this file will get
+incorporated into the Extensions chapter.