<commit_before>angular.module('ngdocs.directives', [], function($compileProvider) {

  var angularJsUrl;
  var scripts = document.getElementsByTagName("script");
  var angularJsRegex = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/;
  for(var j = 0; j < scripts.length; j++) {
    var src = scripts[j].src;
    if (src && src.match(angularJsRegex)) {
      angularJsUrl = src.replace('docs.angularjs.org', 'code.angularjs.org');
      continue;
    }
  }


  var HTML_TEMPLATE =
    '<!doctype html>\n' +
    '<html xmlns:ng="http://angularjs.org" ng:app_MODULE_>\n' +
    ' <script src="' + angularJsUrl + '"></script>\n' +
    '_SCRIPT_SOURCE_' +
    ' <body>\n' +
    '_HTML_SOURCE_\n' +
    ' </body>\n' +
    '</html>';

  $compileProvider.directive('docExample', ['$injector', '$log', '$browser', '$location',
                                    function($injector,   $log,   $browser,   $location) {
    return {
      terminal: true,
      compile: function(element, attrs) {
        var module = attrs.module;

        //jQuery find() methods in this widget contain primitive selectors on purpose so that we can use
        //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName!
        var example = element.find('pre').eq(0),  //doc-source
            scriptSrc = '',
            htmlSrc = example.text().replace(/<script(\s+type="text\/javascript")?>([\s\S]+)<\/script>/im, function(_, type, script) {
                scriptSrc = script;
                return '';
              }),
            showSource = example.attr('source') !== 'false',
            jsfiddle = example.attr('jsfiddle') || true,
            scenario = element.find('pre').eq(1); //doc-scenario

        var tabs = angular.element('<ul class="doc-example">');

        // show source tab, if not disabled
        if (showSource) {
          tabs.append(
            '<li class="doc-example-heading"><h3>Source</h3></li>' +
            '<li class="doc-example-source" ng:non-bindable>' +
            jsFiddleButton(jsfiddle) + // may or may not have value
            '<pre class="brush: js; html-script: true; toolbar: false;"></pre></li>');
        }
        // show live preview tab
        var livePreviewTab;
        tabs.append('<li class="doc-example-heading"><h3>Live Preview</h3></li>');
        tabs.append(livePreviewTab = angular.element('<li class="doc-example-live">' + htmlSrc +'</li>'));
        // show scenario tab, if present
        if (scenario.text()) {
          tabs.append(
            '<li class="doc-example-heading"><h3>Scenario Test</h3></li>' +
            '<li class="doc-example-scenario"><pre class="brush: js">' + scenario.text() + '</pre></li>');
        }

        tabs.find('li').eq(1).find('pre').text(
          HTML_TEMPLATE.
            replace('_SCRIPT_SOURCE_', scriptSrc ? ' <script>\n' + indent(scriptSrc, '  ') + '\n </script>\n'  : '').
            replace('_HTML_SOURCE_', indent(htmlSrc, '  ')).
            replace('_MODULE_', module ? '="' + module + '"' : ''));

        element.html('');
        element.append(tabs);

        try {
          if (window.execScript) { // IE
            window.execScript(scriptSrc || '"stupid IE!"'); // IE complains when evaling empty string
          } else {
            window.eval(scriptSrc);
          }
        } catch (e) {
          alert(e);
        }

        return function(docsAppScope) {
          var modules = [
            function($provide) {
              $provide.value('$browser', $browser);
              $provide.value('$location', $location);
              $provide.decorator('$defer', function($rootScope, $delegate) {
                return angular.extend(function(fn, delay) {
                  if (delay && delay > 500) {
                    return setTimeout(function() {
                      $rootScope.$apply(fn);
                    }, delay);
                  } else {
                    return $delegate.apply(this, arguments);
                  }
                }, $delegate);
              });
            }
          ];
          module && modules.push(module);

          angular.bootstrap(livePreviewTab, modules).
              invoke(['$rootScope', function(example$rootScope) {
                element.bind('$destroy', docsAppScope.$root.$watch(function() {
                  // this propagates the $watch from the docs app to the example app
                  example$rootScope.$digest();
                }));
              }]);
        };

        function jsFiddleButton(jsfiddle) {
          var fixJsFiddleIssue132 = true;
          if (jsfiddle !== 'false') {<commit_msg>fix(docs): Add $locationProvider methods to the docs example provider<commit_after>angular.module('ngdocs.directives', [], function($compileProvider) {

  var angularJsUrl;
  var scripts = document.getElementsByTagName("script");
  var angularJsRegex = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/;
  for(var j = 0; j < scripts.length; j++) {
    var src = scripts[j].src;
    if (src && src.match(angularJsRegex)) {
      angularJsUrl = src.replace('docs.angularjs.org', 'code.angularjs.org');
      continue;
    }
  }


  var HTML_TEMPLATE =
    '<!doctype html>\n' +
    '<html xmlns:ng="http://angularjs.org" ng:app_MODULE_>\n' +
    ' <script src="' + angularJsUrl + '"></script>\n' +
    '_SCRIPT_SOURCE_' +
    ' <body>\n' +
    '_HTML_SOURCE_\n' +
    ' </body>\n' +
    '</html>';

  $compileProvider.directive('docExample', ['$injector', '$log', '$browser', '$location',
                                    function($injector,   $log,   $browser,   $location) {
    return {
      terminal: true,
      compile: function(element, attrs) {
        var module = attrs.module;

        //jQuery find() methods in this widget contain primitive selectors on purpose so that we can use
        //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName!
        var example = element.find('pre').eq(0),  //doc-source
            scriptSrc = '',
            htmlSrc = example.text().replace(/<script(\s+type="text\/javascript")?>([\s\S]+)<\/script>/im, function(_, type, script) {
                scriptSrc = script;
                return '';
              }),
            showSource = example.attr('source') !== 'false',
            jsfiddle = example.attr('jsfiddle') || true,
            scenario = element.find('pre').eq(1); //doc-scenario

        var tabs = angular.element('<ul class="doc-example">');

        // show source tab, if not disabled
        if (showSource) {
          tabs.append(
            '<li class="doc-example-heading"><h3>Source</h3></li>' +
            '<li class="doc-example-source" ng:non-bindable>' +
            jsFiddleButton(jsfiddle) + // may or may not have value
            '<pre class="brush: js; html-script: true; toolbar: false;"></pre></li>');
        }
        // show live preview tab
        var livePreviewTab;
        tabs.append('<li class="doc-example-heading"><h3>Live Preview</h3></li>');
        tabs.append(livePreviewTab = angular.element('<li class="doc-example-live">' + htmlSrc +'</li>'));
        // show scenario tab, if present
        if (scenario.text()) {
          tabs.append(
            '<li class="doc-example-heading"><h3>Scenario Test</h3></li>' +
            '<li class="doc-example-scenario"><pre class="brush: js">' + scenario.text() + '</pre></li>');
        }

        tabs.find('li').eq(1).find('pre').text(
          HTML_TEMPLATE.
            replace('_SCRIPT_SOURCE_', scriptSrc ? ' <script>\n' + indent(scriptSrc, '  ') + '\n </script>\n'  : '').
            replace('_HTML_SOURCE_', indent(htmlSrc, '  ')).
            replace('_MODULE_', module ? '="' + module + '"' : ''));

        element.html('');
        element.append(tabs);

        try {
          if (window.execScript) { // IE
            window.execScript(scriptSrc || '"stupid IE!"'); // IE complains when evaling empty string
          } else {
            window.eval(scriptSrc);
          }
        } catch (e) {
          alert(e);
        }

        return function(docsAppScope) {
          var modules = [
            function($provide) {
              $provide.value('$browser', $browser);
              $provide.service('$location', function() {
                this.$get = function() {
                  return $location;
                };
                this.hashPrefix = this.html5Mode = angular.noop;
              });
              $provide.decorator('$defer', function($rootScope, $delegate) {
                return angular.extend(function(fn, delay) {
                  if (delay && delay > 500) {
                    return setTimeout(function() {
                      $rootScope.$apply(fn);
                    }, delay);
                  } else {
                    return $delegate.apply(this, arguments);
                  }
                }, $delegate);
              });
            }
          ];
          module && modules.push(module);

          angular.bootstrap(livePreviewTab, modules).
              invoke(['$rootScope', function(example$rootScope) {
                element.bind('$destroy', docsAppScope.$root.$watch(function() {
                  // this propagates the $watch from the docs app to the example app
                  example$rootScope.$digest();
                }));
              }]);
        };

        function jsFiddleButton(jsfiddle) {
          var fixJsFiddleIssue132 = true;
          if (jsfiddle !== 'false') {
{'fraction_non_alphanumeric': 0.16806988002525783, 'fraction_numerical': 0.0034729530625131552, 'mean_word_length': 1.9321197161369947, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '951765', 'n_tokens_mistral': 2782, 'n_tokens_neox': 2653, 'n_words': 535}