see doc in Term class
344156
def move(self, place, distance = 1):
        """"""
        x, y = self._get_position()
        if place == 'up':
            y -= distance
        elif place == 'down':
            for i in range(distance): print
            nx, ny = self._get_position()
            y = ny
            self.move('beginning of line')
        elif place == 'left':
            x -= distance
        elif place == 'right':
            x += distance
        elif place == 'beginning of line':
            x = 0
        elif place == 'beginning of screen':
            x = 0
            y = self._get_console_info()['window']['top']
        else:
            raise ValueError("invalid place to move")
        self._set_position((x, y))
1126550
def docroutine(self, object, name, mod=None,
                   funcs={}, classes={}, methods={}, cl=None):
        """"""

        anchor = (cl and cl.__name__ or '') + '-' + name
        note = ''

        title = '<a name="%s"><strong>%s</strong></a>' % (
            self.escape(anchor), self.escape(name))

        if inspect.ismethod(object):
            args = inspect.getfullargspec(object)
            # exclude the argument bound to the instance, it will be
            # confusing to the non-Python user
            argspec = inspect.formatargspec (
                    args.args[1:],
                    args.varargs,
                    args.varkw,
                    args.defaults,
                    annotations=args.annotations,
                    formatvalue=self.formatvalue
                )
        elif inspect.isfunction(object):
            args = inspect.getfullargspec(object)
            argspec = inspect.formatargspec(
                args.args, args.varargs, args.varkw, args.defaults,
                annotations=args.annotations,
                formatvalue=self.formatvalue)
        else:
            argspec = '(...)'

        if isinstance(object, tuple):
            argspec = object[0] or argspec
            docstring = object[1] or ""
        else:
            docstring = pydoc.getdoc(object)

        decl = title + argspec + (note and self.grey(
               '<font face="helvetica, arial">%s</font>' % note))

        doc = self.markup(
            docstring, self.preformat, funcs, classes, methods)
        doc = doc and '<dd><tt>%s</tt></dd>' % doc
        return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
21966
function showDoc (ddoc, viewName, docName, qs, callback) {
      return view(ddoc, viewName + '/' + docName, { type: 'show' }, qs, callback)
    }
359555
def add_term(self, t):
        """"""
        if t not in self.terms:
            if t.parent_term_lc == 'root':
                self.terms.append(t)

                self.doc.add_term(t, add_section=False)

                t.set_ownership()

            else:
                raise GenerateError("Can only add or move root-level terms. Term '{}' parent is '{}' "
                                    .format(t, t.parent_term_lc))

        assert t.section or t.join_lc == 'root.root', t
960494
def get_documents(self, term):
        
        if term not in self._terms:
            raise IndexError(TERM_DOES_NOT_EXIST)
        else:
            return self._terms[term]
570859
def see_doc(obj_with_doc):
    """"""
    def decorator(fn):
        fn.__doc__ = obj_with_doc.__doc__
        return fn
    return decorator
982222
def get_feats(self, doc):
		'''
		
		'''
		ngram_counter = Counter()
		for sent in doc.sents:
			ngrams = self.phrases[str(sent)]
			for subphrases in self.phrases[1:]:
				ngrams = subphrases[str(sent)]
			for ngram in ngrams:
				ngram_counter[ngram] += 1
		return ngram_counter
1267448
def add_term_occurrence(self, term, document):
        
        if document not in self._documents:
            self._documents[document] = 0

        if term not in self._terms:
            if self._freeze:
                return
            else:
                self._terms[term] = collections.Counter()

        if document not in self._terms[term]:
            self._terms[term][document] = 0

        self._documents[document] += 1
        self._terms[term][document] += 1
321816
def _load_documentation(self, term, contents, file_name):
        """"""

        try:
            title = term['title'].value
        except KeyError:
            self.warn("Documentation has no title, skipping: '{}' ".format(term.value))
            return

        if term.term_is('Root.Readme'): # This term type has inline content, not a url
            package_sub_dir = 'docs'
        else:
            try:
                eu = term.expanded_url
                parsed_url = term.parsed_url
            except AttributeError:
                parsed_url = eu = parse_app_url(term.value)

            # Can't used expanded_url here because expansion makes file system URLS absolute.
            if eu.proto == 'file' and not parsed_url.path_is_absolute:
                package_sub_dir = parsed_url.fspath.parent
            else:
                package_sub_dir = 'docs'


        path = join(self.package_path.path,  package_sub_dir, file_name)

        self.prt("Loading documentation for '{}', '{}' to '{}'  ".format(title, file_name, path))

        makedirs(dirname(path), exist_ok=True)

        if exists(path):
            remove(path)

        with open(path, 'wb') as f:
            f.write(contents)
342019
def doc_module(module_name, module, output_dir, source_location, leaf):
    
    path = pathlib.Path(output_dir).joinpath(*module.__name__.split("."))
    available_classes = get_available_classes(module)
    deffed_classes = get_classes(module)
    deffed_funcs = get_funcs(module)
    deffed_enums = get_enums(module)
    alias_funcs = available_classes - deffed_classes
    if leaf:
        doc_path = path.with_suffix(".md")
    else:
        doc_path = path / "index.md"
    doc_path.parent.mkdir(parents=True, exist_ok=True)
    module_path = "/".join(module.__name__.split("."))
    doc = [f"title: {module_name.split('.')[-1]}" + "\n"]
    module_doc = module.__doc__

    # Module overview documentation
    if module_doc is not None:
        doc += to_doc(module.__name__, module, 1, source_location)
    else:
        doc.append(f"# {module.__name__}\n\n")
    doc.append("\n\n")
    for cls_name, cls in sorted(deffed_enums) + sorted(deffed_classes):
        doc += to_doc(cls_name, cls, 2, source_location)

        class_methods = [
            x
            for x in inspect.getmembers(cls, inspect.isfunction)
            if (not x[0].startswith("_")) and deffed_here(x[1], cls)
        ]
        class_methods += inspect.getmembers(cls, lambda o: isinstance(o, property))
        if len(class_methods) > 0:
            doc.append("### Methods \n\n")
            for method_name, method in class_methods:
                doc += to_doc(method_name, method, 4, source_location)
    for fname, func in sorted(deffed_funcs):
        doc += to_doc(fname, func, 2, source_location)
    return doc_path.absolute(), "".join(doc)
185699
@SuppressWarnings("unchecked")
   public TermDocs termDocs(final Term t) throws IOException
   {
      if (t==null || t.field() != field)
      {
         return reader.termDocs(t);
      }

      String text = t.text();
      if (unknownValues.get(text) != null)
      {
         log.debug("EmptyTermDocs({},{})", field, text);
         return EmptyTermDocs.INSTANCE;
      }

      // maintain cache
      CacheEntry entry;
      synchronized (cache)
      {
         entry = (CacheEntry)cache.get(text);
         if (entry == null)
         {
            // check space
            if (cache.size() >= CACHE_SIZE)
            {
               // prune half of them and adjust the rest
               CacheEntry[] entries = (CacheEntry[])cache.values().toArray(new CacheEntry[cache.size()]);
               Arrays.sort(entries);
               int threshold = entries[CACHE_SIZE / 2].numAccessed;
               for (Iterator<Map.Entry<String, CacheEntry>> it = cache.entrySet().iterator(); it.hasNext();)
               {
                  Map.Entry<String, CacheEntry> e = it.next();
                  if (e.getValue().numAccessed <= threshold)
                  {
                     // prune
                     it.remove();
                  }
                  else
                  {
                     // adjust
                     CacheEntry ce = (CacheEntry)e.getValue();
                     ce.numAccessed = (int)Math.sqrt(ce.numAccessed);
                  }
               }
            }
            entry = new CacheEntry();
            cache.put(text, entry);
         }
         else
         {
            entry.numAccessed++;
         }
      }

      // this is a threshold to prevent caching of TermDocs
      // that are read only irregularly.
      if (entry.numAccessed < 10)
      {
         if (log.isDebugEnabled())
         {
            log.debug("#{} TermDocs({},{})", new Object[]{new Integer(entry.numAccessed), field, text});
         }
         return reader.termDocs(t);
      }

      if (entry.bits == null)
      {
         // collect bits
         BitSet bits = null;
         TermDocs tDocs = reader.termDocs(t);
         try
         {
            while (tDocs.next())
            {
               if (bits == null)
               {
                  bits = new BitSet(reader.maxDoc());
               }
               bits.set(tDocs.doc());
            }
         }
         finally
         {
            tDocs.close();
         }
         if (bits != null)
         {
            entry.bits = bits;
         }
      }

      if (entry.bits == null)
      {
         // none collected
         unknownValues.put(text, text);
         return EmptyTermDocs.INSTANCE;
      }
      else
      {
         if (log.isDebugEnabled())
         {
            log.debug("CachedTermDocs({},{},{}/{})", new Object[]{field, text, new Integer(entry.bits.cardinality()),
               new Integer(reader.maxDoc())});
         }
         return new CachedTermDocs(entry.bits);
      }
   }
576844
def _docspec(func, module=None, qualname=None, of_class=None):
    
    sp = _argspec(func)
    doc = _doc_parse(getdoc(func), module=module, qualname=qualname)

    # Merge args
    doc_map = {a.name: a for a in doc.args}
    doc.args = [data.Argument(a, doc_map.get(a.name.lstrip('*'), None)) for a in sp]

    # Args shift: dump `self`
    if (six.PY2 and inspect.ismethod(func)) or \
        (six.PY3 and (inspect.isroutine(func) and of_class is not None) and (of_class is not None and not is_method_static(of_class, func.__name__))):
            doc.args = doc.args[1:]

    # Signature
    doc.update_signature()

    # Finish
    return doc
617902
def classname(ob):
    """"""
    import inspect
    if inspect.isclass(ob):
        return '.'.join([ob.__module__, ob.__name__])
    else:
        return '.'.join([ob.__class__.__module__, ob.__class__.__name__])
901039
def new_term(self, term, value, **kwargs):
        """"""

        tc = self.doc.get_term_class(term.lower())

        t = tc(term, value, doc=self.doc, parent=None, section=self).new_children(**kwargs)

        self.doc.add_term(t)
        return t
697818
def description(self):
        """"""
        try:
            return self.__cog_cleaned_doc__
        except AttributeError:
            self.__cog_cleaned_doc__ = cleaned = inspect.getdoc(self)
            return cleaned
1229664
def visit_class(rec, cls, op):
    # type: (Any, Iterable, Union[Callable[..., Any], partial[Any]]) -> None
    """"""

    if isinstance(rec, MutableMapping):
        if "class" in rec and rec.get("class") in cls:
            op(rec)
        for d in rec:
            visit_class(rec[d], cls, op)
    if isinstance(rec, MutableSequence):
        for d in rec:
            visit_class(d, cls, op)
1146582
def documentation(self, add_to=None):
        """"""
        doc = OrderedDict if add_to is None else add_to

        usage = self.interface.spec.__doc__
        if usage:
            doc['usage'] = usage
        if getattr(self, 'requires', None):
            doc['requires'] = [getattr(requirement, '__doc__', requirement.__name__) for requirement in self.requires]
        doc['outputs'] = OrderedDict()
        doc['outputs']['format'] = self.outputs.__doc__
        doc['outputs']['content_type'] = self.outputs.content_type
        parameters = [param for param in self.parameters if not param in ('request', 'response', 'self')
                                                        and not param in ('api_version', 'body')
                                                        and not param.startswith('hug_')
                                                        and not hasattr(param, 'directive')]
        if parameters:
            inputs = doc.setdefault('inputs', OrderedDict())
            types = self.interface.spec.__annotations__
            for argument in parameters:
                kind = types.get(argument, text)
                if getattr(kind, 'directive', None) is True:
                    continue

                input_definition = inputs.setdefault(argument, OrderedDict())
                input_definition['type'] = kind if isinstance(kind, str) else kind.__doc__
                default = self.defaults.get(argument, None)
                if default is not None:
                    input_definition['default'] = default

        return doc