<commit_before>"""
Interactive help system loader.
"""

import re
import webbrowser

import sublime
from sublime_plugin import WindowCommand, TextCommand

from ...common import util


re_anchor = re.compile(r"^#+ .+", flags=re.MULTILINE)
re_anchor_words = re.compile(r"[a-zA-Z0-9]+")
re_link_scope = re.compile(r"\bmeta\.link\.inline\.markdown\b")


def get_page_and_anchor(view):
    if util.view.get_is_view_of_type(view, "status"):
        return "status.md", None
    if util.view.get_is_view_of_type(view, "tags"):
        return "tag_mgmt.md", "git-tags"
    if util.view.get_is_view_of_type(view, "log_graph"):
        return "history.md", "git-graph"
    if util.view.get_is_view_of_type(view, "branch"):
        return "branch_mgmt.md", "git-branch"
    if util.view.get_is_view_of_type(view, "commit"):
        anchor = ("git-amend-previous-commit"
                  if view.settings().get("git_savvy.commit_view.amend")
                  else None)
        return "commit.md", anchor
    if util.view.get_is_view_of_type(view, "diff"):
        anchor = ("git-diff-cached"
                  if view.settings().get("git_savvy.diff_view.in_cached_mode")
                  else "git-diff")
        return "history.md", anchor

    if util.view.get_is_view_of_type(view, "inline_diff"):
        anchor = ("git-diff-current-file-inline"
                  if view.settings().set("git_savvy.inline_diff.cached")
                  else "git-diff-current-file-inline-cached")
        return "staging.md", anchor

    return "README.md", None


class GsHelp(WindowCommand):

    """
    Load and display GitSavvy help message.  If in special GitSavvy view,
    load view-specific help information.
    """

    def run(self):
        current_view = self.window.active_view()
        page, anchor = get_page_and_anchor(current_view)

        view = util.view.get_read_only_view(self, "help")<commit_msg>Documentation: Show correct contextual help for diff view.<commit_after>"""
Interactive help system loader.
"""

import re
import webbrowser

import sublime
from sublime_plugin import WindowCommand, TextCommand

from ...common import util


re_anchor = re.compile(r"^#+ .+", flags=re.MULTILINE)
re_anchor_words = re.compile(r"[a-zA-Z0-9]+")
re_link_scope = re.compile(r"\bmeta\.link\.inline\.markdown\b")


def get_page_and_anchor(view):
    if util.view.get_is_view_of_type(view, "status"):
        return "status.md", None
    if util.view.get_is_view_of_type(view, "tags"):
        return "tag_mgmt.md", "git-tags"
    if util.view.get_is_view_of_type(view, "log_graph"):
        return "history.md", "git-graph"
    if util.view.get_is_view_of_type(view, "branch"):
        return "branch_mgmt.md", "git-branch"
    if util.view.get_is_view_of_type(view, "commit"):
        anchor = ("git-amend-previous-commit"
                  if view.settings().get("git_savvy.commit_view.amend")
                  else None)
        return "commit.md", anchor
    if util.view.get_is_view_of_type(view, "diff"):
        anchor = ("git-diff-cached"
                  if view.settings().get("git_savvy.diff_view.in_cached_mode")
                  else "git-diff")
        return "staging.md", anchor

    if util.view.get_is_view_of_type(view, "inline_diff"):
        anchor = ("git-diff-current-file-inline"
                  if view.settings().set("git_savvy.inline_diff.cached")
                  else "git-diff-current-file-inline-cached")
        return "staging.md", anchor

    return "README.md", None


class GsHelp(WindowCommand):

    """
    Load and display GitSavvy help message.  If in special GitSavvy view,
    load view-specific help information.
    """

    def run(self):
        current_view = self.window.active_view()
        page, anchor = get_page_and_anchor(current_view)

        view = util.view.get_read_only_view(self, "help")
{'fraction_non_alphanumeric': 0.1309431021044427, 'fraction_numerical': 0.0010392309690828788, 'mean_word_length': 2.900709219858156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '319695', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1274, 'n_words': 244}