| 2795 | #--- DOCUMENT -------------------------------------------------------------------------------------- |
| 2796 | |
| 2797 | class Document(Element): |
| 2798 | |
| 2799 | def __init__(self, html, **kwargs): |
| 2800 | """ Document is the top-level element in the Document Object Model. |
| 2801 | It contains nested Element, Text and Comment nodes. |
| 2802 | """ |
| 2803 | # Aliases for BeautifulSoup optional parameters: |
| 2804 | kwargs["selfClosingTags"] = kwargs.pop("self_closing", kwargs.get("selfClosingTags")) |
| 2805 | Node.__init__(self, u(html).strip(), type=DOCUMENT, **kwargs) |
| 2806 | |
| 2807 | @property |
| 2808 | def declaration(self): |
| 2809 | """ Yields the <!doctype> declaration, as a TEXT Node or None. |
| 2810 | """ |
| 2811 | for child in self.children: |
| 2812 | if isinstance(child._p, BeautifulSoup.Declaration): |
| 2813 | return child |
| 2814 | |
| 2815 | @property |
| 2816 | def head(self): |
| 2817 | return self._wrap(self._p.head) |
| 2818 | @property |
| 2819 | def body(self): |
| 2820 | return self._wrap(self._p.body) |
| 2821 | @property |
| 2822 | def tagname(self): |
| 2823 | return None |
| 2824 | |
| 2825 | tag = tagname |
| 2826 | |
| 2827 | def __repr__(self): |
| 2828 | return "Document()" |
| 2829 | |
| 2830 | DOM = Document |
| 2831 |
no outgoing calls
no test coverage detected
searching dependent graphs…