Create new :class:`Document` object with options.

    :arg bool include_wdom_js: Include wdom.js file. Usually should be True.
    :arg bool include_skeleton: Include skelton.css.
    :arg bool include_normalizecss: Include normalize.css.
    :arg bool autoreload: Enable autoreload flag. This flag overwrites
        ``--debug`` flag, which automatically enables autoreload.
    :arg float reload_wait: Seconds to wait until reload when autoreload is
        enabled.
    :arg str log_level: Log level string, chosen from DEBUG, INFO, WARN, ERROR.
        Integer values are also acceptable like ``logging.INFO``. By default
        use ``wdom.config.options.log_level``, which default is ``INFO``.
    :arg str log_prefix: Prefix of log outputs.
    :arg bool log_console: Flag to show wdom log on browser console.
    :arg str ws_url: URL string to the ws url.
        Default: ``ws://localhost:8888/wdom_ws``.
    :arg float message_wait: Duration (seconds) to send WS messages.
    :arg Callable document_factory: Factory function/class to create Document
        object.
    :rtype: Document

def get_new_document(  # noqa: C901
        include_wdom_js: bool = True,
        include_skeleton: bool = False,
        include_normalizecss: bool = False,
        autoreload: bool = None,
        reload_wait: float = None,
        log_level: Union[int, str] = None,
        log_prefix: str = None,
        log_console: bool = False,
        ws_url: str = None,
        message_wait: float = None,
        document_factory: Callable[..., Document] = WdomDocument,
        **kwargs: Any) -> Document:
    """Create new :class:`Document` object with options.

    :arg bool include_wdom_js: Include wdom.js file. Usually should be True.
    :arg bool include_skeleton: Include skelton.css.
    :arg bool include_normalizecss: Include normalize.css.
    :arg bool autoreload: Enable autoreload flag. This flag overwrites
        ``--debug`` flag, which automatically enables autoreload.
    :arg float reload_wait: Seconds to wait until reload when autoreload is
        enabled.
    :arg str log_level: Log level string, chosen from DEBUG, INFO, WARN, ERROR.
        Integer values are also acceptable like ``logging.INFO``. By default
        use ``wdom.config.options.log_level``, which default is ``INFO``.
    :arg str log_prefix: Prefix of log outputs.
    :arg bool log_console: Flag to show wdom log on browser console.
    :arg str ws_url: URL string to the ws url.
        Default: ``ws://localhost:8888/wdom_ws``.
    :arg float message_wait: Duration (seconds) to send WS messages.
    :arg Callable document_factory: Factory function/class to create Document
        object.
    :rtype: Document
    """
    document = document_factory(
        autoreload=autoreload,
        reload_wait=reload_wait,
        **kwargs
    )

    if log_level is None:
        log_level = config.logging
    if message_wait is None:
        message_wait = config.message_wait

    log_script = []
    log_script.append('var WDOM_MESSAGE_WAIT = {}'.format(message_wait))
    if isinstance(log_level, str):
        log_script.append('var WDOM_LOG_LEVEL = \'{}\''.format(log_level))
    elif isinstance(log_level, int):
        log_script.append('var WDOM_LOG_LEVEL = {}'.format(log_level))
    if log_prefix:
        log_script.append('var WDOM_LOG_PREFIX = \'{}\''.format(log_prefix))
    if log_console:
        log_script.append('var WDOM_LOG_CONSOLE = true')
    if log_script:
        _s = Script(parent=document.head)
        _s.textContent = '\n{}\n'.format('\n'.join(log_script))

    if ws_url:
        _s = Script(parent=document.head)
        _s.textContent = '\nvar WDOM_WS_URL = \'{}\'\n'.format(ws_url)

    if include_wdom_js:
        document.add_jsfile_head('_static/js/wdom.js')

    return document