From 1ec0ab2d565116ce12a8f8ce9fba7b0aa5c14b7f Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 2 Nov 2001 08:27:56 +0000 Subject: [PATCH] Extend the capabilities of the program2html processor and accompanied machinery to allow for subsection headers within programs, in order to better structurize long program texts. git-svn-id: https://svn.dealii.org/trunk@5179 0785d39b-7218-0410-832d-ea1e28bc413d --- .../tutorial/chapter-2.step-by-step/Makefile | 8 ++++- .../tutorial/chapter-2.step-by-step/head.html | 3 ++ .../chapter-2.step-by-step/program2html | 17 +++++++-- deal.II/examples/step-7/step-7.cc | 35 ++++++++++++------- deal.II/examples/step-9/step-9.cc | 8 ++++- 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/deal.II/doc/tutorial/chapter-2.step-by-step/Makefile b/deal.II/doc/tutorial/chapter-2.step-by-step/Makefile index ed9b7ebf02..4d386c386f 100644 --- a/deal.II/doc/tutorial/chapter-2.step-by-step/Makefile +++ b/deal.II/doc/tutorial/chapter-2.step-by-step/Makefile @@ -14,10 +14,16 @@ all: $(example-htmls) $(example-htmls): @echo ================== Assembling $@ - @cat head.html \ + @TOC=`cat $D/examples/$(@:.html=)/$(@:.html=.cc) \ + | grep "@sect" \ + | perl -pi -e 's/.*\{(.*)\}.*/\1/; $$n=$$1; $$nn=$$1; \ + $$nn=~s/\s/_/g; $$_="
  • $$n
  • \n";' \ + | perl -pi -e 's/\"/\\\"/g;'` ; \ + cat head.html \ | perl -pi -e '$$step="$@"; \ $$step=~s/step-(\d+).html/$$1/g; \ s/step xxx/step $$step/g;' \ + | perl -pi -e "s!TOC!$$TOC!g;" \ > $@ @cat $(@:.html=.data/intro.html) >> $@ @cat $D/examples/$(@:.html=)/$(@:.html=.cc) \ diff --git a/deal.II/doc/tutorial/chapter-2.step-by-step/head.html b/deal.II/doc/tutorial/chapter-2.step-by-step/head.html index 57bb61426c..6e5cab2015 100644 --- a/deal.II/doc/tutorial/chapter-2.step-by-step/head.html +++ b/deal.II/doc/tutorial/chapter-2.step-by-step/head.html @@ -21,6 +21,9 @@
    1. Introduction
    2. The commented program +
        + TOC +
    3. Results
    4. The plain program
    diff --git a/deal.II/doc/tutorial/chapter-2.step-by-step/program2html b/deal.II/doc/tutorial/chapter-2.step-by-step/program2html index 6e3c359e2c..41c836f8b3 100644 --- a/deal.II/doc/tutorial/chapter-2.step-by-step/program2html +++ b/deal.II/doc/tutorial/chapter-2.step-by-step/program2html @@ -44,8 +44,21 @@ while (<>) { if ($state == $comment_mode) { - m!\s*//\s*(.*)!; - print $1, "\n"; + # in comment mode: first skip leading whitespace and + # comment // signs + s!\s*//\s*(.*)!$1!; + + # second, replace section headers, and generate addressable + # anchor + s!\@sect(\d)\{(.*)\}\s*$!$2!g; + $sect_name = $2; + $sect_name =~ s/\s/_/g; + $_ = "\n" . $_; + + # finally print this line + print $_, "\n"; + + # if empty line, introduce paragraph break print "

    \n\n

    " if $1 =~ m!^\s*$!; } else diff --git a/deal.II/examples/step-7/step-7.cc b/deal.II/examples/step-7/step-7.cc index 0f1ea66874..10e939827c 100644 --- a/deal.II/examples/step-7/step-7.cc +++ b/deal.II/examples/step-7/step-7.cc @@ -73,19 +73,26 @@ #include - - // Since we want to compare the - // exactly known continuous solution - // to the computed one, we need a - // function object which represents - // the continuous solution. On the - // other hand, we need the right hand - // side function, and that one of - // course shares some characteristics - // with the solution. In order to - // reduce dependencies which arise if - // we have to change something in - // both classes at the same time, we + // @sect3{Equation data} + + // Before implementing the classes + // that actually solve something, we + // first declare and define some + // function classes that represent + // right hand side and solution + // classes. Since we want to compare + // the exactly known continuous + // solution to the computed one, we + // need a function object which + // represents the continuous + // solution. On the other hand, we + // need the right hand side function, + // and that one of course shares some + // characteristics with the + // solution. In order to reduce + // dependencies which arise if we + // have to change something in both + // classes at the same time, we // exclude the common characteristics // of both functions into a base // class. @@ -331,6 +338,7 @@ double RightHandSide::value (const Point &p, }; + // @sect3{The Laplace solver class} // Then we need the class that does // all the work. It is mostly the @@ -1732,6 +1740,7 @@ void LaplaceProblem::run () } }; + // @sect3{Main function} // The main function is mostly as // before. The only difference is diff --git a/deal.II/examples/step-9/step-9.cc b/deal.II/examples/step-9/step-9.cc index e2f811f86e..c735d66bcc 100644 --- a/deal.II/examples/step-9/step-9.cc +++ b/deal.II/examples/step-9/step-9.cc @@ -77,6 +77,7 @@ # define M_PI 3.14159265358979323846 #endif + // @sect3{AdvectionProblem class declaration} // Following we declare the main // class of this program. It is very @@ -183,6 +184,7 @@ class AdvectionProblem + // @sect3{Equation data declaration} // Next we declare a class that // describes the advection @@ -494,6 +496,7 @@ BoundaryValues::value_list (const std::vector > &points, + // @sect3{GradientEstimation class declaration} // Now, finally, here comes the class // that will compute the difference @@ -620,7 +623,7 @@ class GradientEstimation - + // @sect3{AdvectionProblem class implementation} // Now for the implementation of the @@ -1410,6 +1413,7 @@ void AdvectionProblem::run () + // @sect3{GradientEstimation class implementation} // Now for the implementation of the // ``GradientEstimation'' class. The @@ -2030,6 +2034,8 @@ GradientEstimation::estimate_interval (const DoFHandler &dof_handler, }; + // @sect3{Main function} + // The ``main'' function is exactly // like in previous examples, with // the only difference in the name of -- 2.39.5