Ticket #4714: trac_4714-minimal_doc.patch

File trac_4714-minimal_doc.patch, 8.1 KB (added by mpatel, 12 years ago)

Minimal approach for docs. Depends on #6614.

  • doc/common/conf.py

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1249359039 25200
    # Node ID 91f5a126afe7a84eb5d08a8e54c970c690b14738
    # Parent  314d1fdb7f96cddd9e13f4fb75f4666302a7baa1
    #4714, jsMath for docs with Sage customizations, via static/jsmath_sage.js
    
    diff --git a/doc/common/conf.py b/doc/common/conf.py
    a b if 'SAGE_DOC_JSMATH' in os.environ: 
    1818    extensions.append('sphinx.ext.jsmath')
    1919else:
    2020    extensions.append('sphinx.ext.pngmath')
    21 jsmath_path = 'easy/load.js'
     21jsmath_path = 'jsmath_sage.js'
    2222
    2323# Add any paths that contain templates here, relative to this directory.
    2424templates_path = [os.path.join(SAGE_DOC, 'common/templates'), 'templates']
  • new file doc/common/static/jsmath_sage.js

    diff --git a/doc/common/static/jsmath_sage.js b/doc/common/static/jsmath_sage.js
    new file mode 100644
    - +  
     1/**********************************************************************
     2 *
     3 *   Customize the values given below to suit your needs.
     4 *   You can make additional copies of this file with
     5 *   different customizated settings if you need to load
     6 *   jsMath with different parameters.
     7 *
     8 *   Load this page via:
     9 *
     10 *   <SCRIPT SRC="path-to-jsMath/easy/load.js"></SCRIPT>
     11 *
     12 *   (If you are including this file into your page via Server-Side
     13 *   Includes, you should remove line above.)
     14 *
     15 *   You can make copies of this file with different settings
     16 *   if you need to have several different configurations.
     17 *
     18 **********************************************************************/
     19
     20    if (!window.jsMath) {window.jsMath = {}}
     21
     22//  Move the jsMath button 20 pixels from the right edge (apparently
     23//  in some browsers, it covers up the scroll bar)
     24jsMath.styles = {
     25    '#jsMath_button' : 'position:fixed; bottom:1px; right:20px; '
     26        + 'background-color:white; border: solid 1px #959595; margin:0px; '
     27        + 'padding: 0px 3px 1px 3px; z-index:102; color:black; '
     28        + 'text-decoration:none; font-size:x-small; width:auto; cursor:hand;'
     29}
     30
     31jsMath.Easy = {
     32    //
     33    //  The URL of the root jsMath directory on your server
     34    //  (it must be in the same domain as the HTML page).
     35    //  It should include "http://yoursite.com/", or should
     36    //  be relative to the root of your server.  It is possible
     37    //  to be a relative URL, but it will be relative to the
     38    //  HTML page loading this file.
     39    //
     40    //  If you leave this blank, jsMath will try to look it up from
     41    //  the URL where it loaded this file, but that may not work.
     42    //
     43    root: "",
     44
     45    //
     46    //  The default scaling factor for mathematics compared to the
     47    //  surrounding text.
     48    //
     49    scale: 115,
     50
     51    //
     52    //  1 means use the autoload plug-in to decide if jsMath should be loaded
     53    //  0 means always load jsMath
     54    //
     55    autoload: 1,
     56
     57    //
     58    //  Setting any of these will cause the tex2math plugin to be used
     59    //  to add the <DIV> and <SPAN> tags that jsMath needs.  See the
     60    //  documentation for the tex2math plugin for more information.
     61    //
     62    processSlashParens: 1,       // process \(...\) in text?
     63    processSlashBrackets: 1,     // process \[...\] in text?
     64    processDoubleDollars: 1,     // process $$...$$ in text?
     65    processSingleDollars: 0,     // process $...$ in text?
     66    processLaTeXenvironments: 0, // process \begin{xxx}...\end{xxx} outside math mode?
     67    fixEscapedDollars: 0,        // convert \$ to $ outside of math mode?
     68    doubleDollarsAreInLine: 0,   // make $$...$$ be in-line math?
     69    allowDisableTag: 1,          // allow ID="tex2math_off" to disable tex2math?
     70    //
     71    //  If you want to use your own custom delimiters for math instead
     72    //  of the usual ones, then uncomment the following four lines and
     73    //  insert your own delimiters within the quotes.  You may want to
     74    //  turn off processing of the dollars and other delimiters above
     75    //  as well, though you can use them in combination with the
     76    //  custom delimiters if you wish.  See the tex2math documentation
     77    //  for more details.
     78    //
     79    //customDelimiters: [
     80    //  '[math]','[/math]',        // to begin and end in-line math
     81    //  '[display]','[/display]'   // to begin and end display math
     82    //],
     83
     84    //
     85    //  Disallow the use of the @(...) mechanism for including raw HTML
     86    //  in the contents of \hbox{}?  (If used in a content-management system
     87    //  where users are allowed to enter mathematics, setting this to 0
     88    //  would allow them to enter arbitrary HTML code within their
     89    //  math formulas, and that poses a security risk.)
     90    //
     91    safeHBoxes: 1,
     92
     93    //
     94    //  Show TeX source when mathematics is double-clicked?
     95    //
     96    allowDoubleClicks: 1,
     97
     98    //
     99    //  Show jsMath font warning messages?  (Disabling this prevents yours
     100    //  users from finding out that they can have a better experience on your
     101    //  site by installing some fonts, so don't disable this).
     102    //
     103    showFontWarnings: 0,
     104
     105    //
     106    //  Use "Process" or "ProcessBeforeShowing".  See the jsMath
     107    //  author's documentation for the difference between these
     108    //  two routines.
     109    //
     110    method: "Process",
     111
     112    //
     113    //  List of plug-ins and extensions that you want to be
     114    //  loaded automatically.  E.g.
     115    //      ["plugins/mimeTeX.js","extensions/AMSsymbols.js"]
     116    //
     117    loadFiles: [
     118        "extensions/verb.js",
     119        "extensions/moreArrows.js",
     120        "extensions/AMSmath.js",
     121        "extensions/AMSsymbols.js"
     122    ],
     123
     124    //
     125    //  List of fonts to load automatically.  E.g.
     126    //      ["cmmib10"]
     127    //
     128    loadFonts: [],
     129
     130    //
     131    //  List of macros to define.  These are of the form
     132    //      name: value
     133    //  where 'value' is the replacement text for the macro \name.
     134    //  The 'value' can also be [value,n] where 'value' is the replacement
     135    //  text and 'n' is the number of parameters for the macro.
     136    //  Note that backslashes must be doubled in the replacement string.
     137    //  E.g.,
     138    //      {
     139    //        RR: '{\\bf R}',
     140    //        bold: ['{\\bf #1}', 1]
     141    //      }
     142    //
     143    // Sage-specific jsMath macros.
     144    macros: {
     145        ZZ : '{\\Bold{Z}}',
     146        RR : '{\\Bold{R}}',
     147        CC : '{\\Bold{C}}',
     148        QQ : '{\\Bold{Q}}',
     149        QQbar : '{\\overline{\\QQ}}',
     150        GF : ['{\\Bold{F}_{#1}}', 1],
     151        Zp : ['{\\ZZ_{#1}}', 1],
     152        Qp : ['{\\QQ_{#1}}', 1],
     153        Zmod : ['{\\ZZ/#1\\ZZ}', 1],
     154        CDF : '{\\text{Complex Double Field}}',
     155        CIF : '{\\Bold{C}}',
     156        CLF : '{\\Bold{C}}',
     157        RDF : '{\\Bold{R}}',
     158        RIF : '{\\I \\R}',
     159        RLF : '{\\Bold{R}}',
     160        RQDF : '{\\Bold{R}}',
     161        CFF : '{\\Bold{CFF}}',
     162        Bold : ['{\\mathbf{#1}}', 1]
     163    },
     164
     165    //
     166    //  Allow jsMath to enter global mode?
     167    //  (Uses frames, so may not always work with complex web sites)
     168    //
     169    allowGlobal: 1,
     170
     171    //
     172    //  Disable image fonts?  (In case you don't load them on your server.)
     173    //
     174    // If we set this to 1, we do not need to load plugins/noImageFonts.js
     175    noImageFonts: 1
     176};
     177
     178/****************************************************************/
     179/****************************************************************/
     180//
     181//            DO NOT MAKE CHANGES BELOW THIS
     182//
     183/****************************************************************/
     184/****************************************************************/
     185
     186jsMath.Easy.find_root = function () {
     187    if (jsMath.Easy.root == "") {
     188        jsMath.Easy.root = document.getElementsByTagName("script");
     189        for (var i = 0; i < jsMath.Easy.root.length; i++) {
     190            if (jsMath.Easy.root[i].src.match(/doctools.js$/)) {
     191                jsMath.Easy.root = jsMath.Easy.root[i].src.replace(/doctools.js$/, "");
     192                return;
     193            }
     194        }
     195        jsMath.Easy.root = jsMath.Easy.root[jsMath.Easy.root.length-1].src
     196        if (jsMath.Easy.root.match(/\/easy\/[^\/]*$/)) {
     197            jsMath.Easy.root = jsMath.Easy.root.replace(/\/easy\/[^\/]*$/,"");
     198        } else {
     199            jsMath.Easy.root = jsMath.Easy.root.replace(/\/(jsMath\/(easy\/)?)?[^\/]*$/,"/jsMath");
     200        }
     201    }
     202};
     203
     204jsMath.Easy.find_root();
     205
     206jsMath.Easy.root = jsMath.Easy.root.replace(/\/$/,""); // trim trailing "/" if any
     207
     208document.write('<SCRIPT SRC="'+jsMath.Easy.root+'/jsMath-easy-load.js"><'+'/SCRIPT>');