code: def get_pydoc_completions(modulename):
      
      modulename = compat.ensure_not_unicode(modulename)
      modulename = modulename.rstrip(".")
      if modulename == "":
          return sorted(get_modules())
      candidates = get_completions(modulename)
      if candidates:
          return sorted(candidates)
      needle = modulename
      if "." in needle:
          modulename, part = needle.rsplit(".", 1)
          candidates = get_completions(modulename)
      else:
          candidates = get_modules()
      return sorted(candidate for candidate in candidates
                    if candidate.startswith(needle))
docs: Get possible completions for modulename for pydoc.
  
      Returns a list of possible values to be passed to pydoc.