Exemple #1
0
 def test_find_title(self):
     p2_html = sitegen.render_html('subdir/page2', self.config, self.soups,
                                   self.precomputed, '{{title}}')
     self.assertEqual(p2_html, 'Page 2: Electric Boogaloo',
                      """Didn't find correct title""")
     # ascii worked? great, try non-ASCII
     p1_html = sitegen.render_html('subdir/page1', self.config, self.soups,
                                   self.precomputed, '{{title}}')
     self.assertEqual(p1_html, u'東京 is Tokyo',
                      """Didn't find correct non-ASCII title""")
Exemple #2
0
 def test_pantsrefs(self):
     sitegen.link_pantsrefs(self.soups, self.precomputed)
     p1_html = sitegen.render_html('subdir/page1', self.config, self.soups,
                                   self.precomputed, TEMPLATE_MUSTACHE)
     self.assertIn('href="../index.html#pantsmark_index"', p1_html,
                   'pantsref_index did not get linked')
     p2_html = sitegen.render_html('subdir/page2', self.config, self.soups,
                                   self.precomputed, TEMPLATE_MUSTACHE)
     self.assertIn('href="page1.html#an_pantsmark"', p2_html,
                   'pantsref_p1 did not get linked')
Exemple #3
0
 def test_pantsrefs(self):
   sitegen.link_pantsrefs(self.soups, self.precomputed)
   p1_html = sitegen.render_html('subdir/page1',
                                 self.config,
                                 self.soups,
                                 self.precomputed,
                                 TEMPLATE_MUSTACHE)
   self.assertIn('href="../index.html#pantsmark_index"', p1_html,
                 'pantsref_index did not get linked')
   p2_html = sitegen.render_html('subdir/page2',
                                 self.config,
                                 self.soups,
                                 self.precomputed,
                                 TEMPLATE_MUSTACHE)
   self.assertIn('href="page1.html#an_pantsmark"', p2_html,
                 'pantsref_p1 did not get linked')
Exemple #4
0
 def test_find_title(self):
   p2_html = sitegen.render_html('subdir/page2',
                                 self.config,
                                 self.soups,
                                 self.precomputed,
                                 '{{title}}')
   self.assertEqual(p2_html, 'Page 2: Electric Boogaloo',
                    """Didn't find correct title""")
   # ascii worked? great, try non-ASCII
   p1_html = sitegen.render_html('subdir/page1',
                                 self.config,
                                 self.soups,
                                 self.precomputed,
                                 '{{title}}')
   self.assertEqual(p1_html, u'東京 is Tokyo',
                    """Didn't find correct non-ASCII title""")
Exemple #5
0
 def test_xrefs(self):
   soups = self.orig_soups.copy()
   sitegen.link_xrefs(soups, self.precomputed)
   p1_html = sitegen.render_html('subdir/page1',
                                 self.config,
                                 soups,
                                 self.precomputed,
                                 TEMPLATE_MUSTACHE)
   self.assertIn('href="../index.html#xmark_index"', p1_html,
                 'xref_index did not get linked')
   p2_html = sitegen.render_html('subdir/page2',
                                 self.config,
                                 soups,
                                 self.precomputed,
                                 TEMPLATE_MUSTACHE)
   self.assertIn('href="page1.html#an_xmark"', p2_html,
                 'xref_p1 did not get linked')
Exemple #6
0
 def test_find_title(self):
   soups = self.orig_soups.copy()
   html = sitegen.render_html('subdir/page2',
                              self.config,
                              soups,
                              self.precomputed,
                              '{{title}}')
   self.assertEqual(html, 'Page 2: Electric Boogaloo',
                    '''Didn't find correct title''')
Exemple #7
0
 def test_here_links(self):
   sitegen.add_here_links(self.soups)
   html = sitegen.render_html('index',
                              self.config,
                              self.soups,
                              self.precomputed,
                              TEMPLATE_MUSTACHE)
   self.assertIn('href="#pants-build-system"', html,
                 'Generated html lacks auto-created link to h1.')
Exemple #8
0
 def test_fixup_internal_links(self):
   sitegen.fixup_internal_links(self.config, self.soups)
   html = sitegen.render_html('index',
                              self.config,
                              self.soups,
                              self.precomputed,
                              TEMPLATE_MUSTACHE)
   self.assertIn('subdir/page1.html', html,
                 'p1.html link did not get fixed up to page1.html')
Exemple #9
0
 def test_fixup_internal_links(self):
   sitegen.fixup_internal_links(self.config, self.soups)
   html = sitegen.render_html('index',
                              self.config,
                              self.soups,
                              self.precomputed,
                              TEMPLATE_MUSTACHE)
   self.assertIn('subdir/page1.html', html,
                 'p1.html link did not get fixed up to page1.html')
Exemple #10
0
 def test_transform_fixes_up_internal_links(self):
   sitegen.transform_soups(self.config, self.soups, self.precomputed)
   html = sitegen.render_html('index',
                              self.config,
                              self.soups,
                              self.precomputed,
                              TEMPLATE_MUSTACHE)
   self.assertTrue('subdir/page1.html' in html,
                   'p1.html link did not get fixed up to page1.html')
Exemple #11
0
 def test_transform_fixes_up_internal_links(self):
   sitegen.transform_soups(self.config, self.soups, self.precomputed)
   html = sitegen.render_html('index',
                              self.config,
                              self.soups,
                              self.precomputed,
                              TEMPLATE_MUSTACHE)
   self.assertTrue('subdir/page1.html' in html,
                   'p1.html link did not get fixed up to page1.html')
Exemple #12
0
 def test_no_show_toc(self):
     sitegen.generate_page_tocs(self.soups, self.precomputed)
     rendered = sitegen.render_html(
         'subdir/page2_no_toc', self.config, self.soups, self.precomputed,
         """
                                {{#page_toc}}
                                DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                {{/page_toc}}
                                """)
     self.assertNotIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
     self.assertNotIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #13
0
 def test_breadcrumbs(self):
     # Our "site" has a simple outline.
     # Do we get the correct info from that to generate
     # "breadcrumbs" navigating from one page up to the top?
     rendered = sitegen.render_html(
         'subdir/page2', self.config, self.soups, self.precomputed, """
                                {{#breadcrumbs}}
                                LINK={{link}} TEXT={{text}}
                                {{/breadcrumbs}}
                                """)
     self.assertIn('LINK=../index.html TEXT=Pants Build System', rendered)
Exemple #14
0
 def test_transforms_not_discard_page_tocs(self):
     # We had a bug where one step of transform lost the info
     # we need to build page-tocs. Make sure that doesn't happen again.
     sitegen.transform_soups(self.config, self.soups, self.precomputed)
     rendered = sitegen.render_html(
         'subdir/page2', self.config, self.soups, self.precomputed, """
                                {{#page_toc}}
                                DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                {{/page_toc}}
                                """)
     self.assertIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
     self.assertIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #15
0
 def test_page_toc(self):
     # One of our "pages" has a couple of basic headings.
     # Do we get the correct info from that to generate
     # a page-level table of contents?
     sitegen.generate_page_tocs(self.soups, self.precomputed)
     rendered = sitegen.render_html(
         'subdir/page2', self.config, self.soups, self.precomputed, """
                                {{#page_toc}}
                                DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                {{/page_toc}}
                                """)
     self.assertIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
     self.assertIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #16
0
 def test_no_show_toc(self):
   sitegen.generate_page_tocs(self.soups, self.precomputed)
   rendered = sitegen.render_html('subdir/page2_no_toc',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#page_toc}}
                                  DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                  {{/page_toc}}
                                  """)
   self.assertNotIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
   self.assertNotIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #17
0
 def test_breadcrumbs(self):
   # Our "site" has a simple outline.
   # Do we get the correct info from that to generate
   # "breadcrumbs" navigating from one page up to the top?
   rendered = sitegen.render_html('subdir/page2',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#breadcrumbs}}
                                  LINK={{link}} TEXT={{text}}
                                  {{/breadcrumbs}}
                                  """)
   self.assertIn('LINK=../index.html TEXT=Pants Build System', rendered)
Exemple #18
0
 def test_site_toc(self):
     # Our "site" has a simple outline.
     # Do we get the correct info from that to generate
     # a site-level table of contents?
     rendered = sitegen.render_html(
         'index', self.config, self.soups, self.precomputed, """
                                {{#site_toc}}
                                DEPTH={{depth}} LINK={{links}} HEADING={{heading}} 
                                {{/site_toc}}
                                """)
     self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
     self.assertIn(
         u"DEPTH=1 LINK=[{'text': u'Page 2: Electric Boogaloo', 'link': u'subdir/page2.html', 'here': False}, {'text': u'Pants Build System', 'link': u'index.html', 'here': True}] HEADING=collapse",
         rendered)
Exemple #19
0
 def test_site_toc(self):
   # Our "site" has a simple outline.
   # Do we get the correct info from that to generate
   # a site-level table of contents?
   rendered = sitegen.render_html('index',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#site_toc}}
                                  DEPTH={{depth}} LINK={{links}} HEADING={{heading}} 
                                  {{/site_toc}}
                                  """)
   self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
   self.assertIn(u"DEPTH=1 LINK=[{'text': u'Page 2: Electric Boogaloo', 'link': u'subdir/page2.html', 'here': False}, {'text': u'Pants Build System', 'link': u'index.html', 'here': True}] HEADING=collapse", rendered)
Exemple #20
0
 def test_site_toc(self):
     # Our "site" has a simple outline.
     # Do we get the correct info from that to generate
     # a site-level table of contents?
     rendered = sitegen.render_html(
         'index', self.config, self.soups, self.precomputed, """
                                {{#site_toc}}
                                DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                {{/site_toc}}
                                """)
     self.assertIn(u'DEPTH=1 LINK=subdir/page1.html TEXT=東京 is Tokyo',
                   rendered)
     self.assertIn(
         'DEPTH=1 LINK=subdir/page2.html TEXT=Page 2: Electric Boogaloo',
         rendered)
Exemple #21
0
 def test_site_toc(self):
   # Our "site" has a simple outline.
   # Do we get the correct info from that to generate
   # a site-level table of contents?
   rendered = sitegen.render_html('index',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#site_toc}}
                                  DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                  {{/site_toc}}
                                  """)
   self.assertIn(u'DEPTH=1 LINK=subdir/page1.html TEXT=東京 is Tokyo', rendered)
   self.assertIn('DEPTH=1 LINK=subdir/page2.html TEXT=Page 2: Electric Boogaloo', rendered)
Exemple #22
0
 def test_transforms_not_discard_page_tocs(self):
   # We had a bug where one step of transform lost the info
   # we need to build page-tocs. Make sure that doesn't happen again.
   sitegen.transform_soups(self.config, self.soups, self.precomputed)
   rendered = sitegen.render_html('subdir/page2',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#page_toc}}
                                  DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                  {{/page_toc}}
                                  """)
   self.assertIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
   self.assertIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #23
0
 def test_page_toc(self):
   # One of our "pages" has a couple of basic headings.
   # Do we get the correct info from that to generate
   # a page-level table of contents?
   sitegen.generate_page_tocs(self.soups, self.precomputed)
   rendered = sitegen.render_html('subdir/page2',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#page_toc}}
                                  DEPTH={{depth}} LINK={{link}} TEXT={{text}}
                                  {{/page_toc}}
                                  """)
   self.assertIn('DEPTH=1 LINK=one TEXT=Section One', rendered)
   self.assertIn('DEPTH=1 LINK=two TEXT=Section Two', rendered)
Exemple #24
0
 def test_site_toc(self):
     # Our "site" has a simple outline.
     # Do we get the correct info from that to generate
     # a site-level table of contents?
     rendered = sitegen.render_html(
         'index', self.config, self.soups, self.precomputed, """
                                {{#site_toc}}
                                DEPTH={{depth}} LINK={{links}} HEADING={{heading}} 
                                {{/site_toc}}
                                """)
     self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
     escaped_single_quote = '''
     rendered_expected = (
         "DEPTH=1 LINK=[{{{q}link{q}: {q}subdir/page2.html{q}, {q}text{q}: {q}Page 2: Electric Boogaloo{q}, {q}here{q}: False}}, "
         "{{{q}link{q}: {q}index.html{q}, {q}text{q}: {q}Pants Build System{q}, {q}here{q}: True}}] HEADING=collapse"
         .format(q=escaped_single_quote))
     self.assertIn(rendered_expected, rendered)
Exemple #25
0
 def test_site_toc(self):
     # Our "site" has a simple outline.
     # Do we get the correct info from that to generate
     # a site-level table of contents?
     rendered = sitegen.render_html(
         'index', self.config, self.soups, self.precomputed, """
                                {{#site_toc}}
                                DEPTH={{depth}} LINK={{links}} HEADING={{heading}} 
                                {{/site_toc}}
                                """)
     self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
     # Py2 and Py3 order the elements differently and Py3 doesn't render 'u' in unicode literals. Both are valid.
     rendered_expected = (
         "DEPTH=1 LINK=[{'link': 'subdir/page2.html', 'text': 'Page 2: Electric Boogaloo', 'here': False}, "
         "{'link': 'index.html', 'text': 'Pants Build System', 'here': True}] HEADING=collapse"
         if PY3 else
         "DEPTH=1 LINK=[{'text': u'Page 2: Electric Boogaloo', 'link': u'subdir/page2.html', 'here': False}, "
         "{'text': u'Pants Build System', 'link': u'index.html', 'here': True}] HEADING=collapse"
     )
     self.assertIn(rendered_expected, rendered)
Exemple #26
0
 def test_site_toc(self):
   # Our "site" has a simple outline.
   # Do we get the correct info from that to generate
   # a site-level table of contents?
   rendered = sitegen.render_html('index',
                                  self.config,
                                  self.soups,
                                  self.precomputed,
                                  """
                                  {{#site_toc}}
                                  DEPTH={{depth}} LINK={{links}} HEADING={{heading}} 
                                  {{/site_toc}}
                                  """)
   self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
   escaped_single_quote = '''
   # Py2 and Py3 order the elements differently and Py3 doesn't render 'u' in unicode literals. Both are valid.
   rendered_expected = ("DEPTH=1 LINK=[{{{q}link{q}: {q}subdir/page2.html{q}, {q}text{q}: {q}Page 2: Electric Boogaloo{q}, {q}here{q}: False}}, "
                        "{{{q}link{q}: {q}index.html{q}, {q}text{q}: {q}Pants Build System{q}, {q}here{q}: True}}] HEADING=collapse".format(q=escaped_single_quote)
                        if PY3 else
                        "DEPTH=1 LINK=[{{{q}text{q}: u{q}Page 2: Electric Boogaloo{q}, {q}link{q}: u{q}subdir/page2.html{q}, {q}here{q}: False}}, "
                        "{{{q}text{q}: u{q}Pants Build System{q}, {q}link{q}: u{q}index.html{q}, {q}here{q}: True}}] HEADING=collapse".format(q=escaped_single_quote))
   self.assertIn(rendered_expected, rendered)
Exemple #27
0
 def test_here_links(self):
     sitegen.add_here_links(self.soups)
     html = sitegen.render_html('index', self.config, self.soups,
                                self.precomputed, TEMPLATE_MUSTACHE)
     self.assertIn('href="#pants-build-system"', html,
                   'Generated html lacks auto-created link to h1.')