Add highlight search to search_code function (#925)

*  add highlight search to search_code function

*  add highlighting search code tests
This commit is contained in:
h.shi
2018-10-10 16:38:47 +08:00
committed by Wan Liuyang
parent c13b43ea9c
commit 1fa25670f7
6 changed files with 39 additions and 3 deletions
+6 -3
View File
@@ -459,12 +459,13 @@ class Github(object):
url_parameters
)
def search_code(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers):
def search_code(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, highlight=False, **qualifiers):
"""
:calls: `GET /search/code <http://developer.github.com/v3/search>`_
:param query: string
:param sort: string ('indexed')
:param order: string ('asc', 'desc')
:param highlight: boolean (True, False)
:param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile`
"""
@@ -487,14 +488,16 @@ class Github(object):
url_parameters["q"] = ' '.join(query_chunks)
assert url_parameters["q"], "need at least one qualifier"
headers = {"Accept": Consts.highLightSearchPreview} if highlight else None
return github.PaginatedList.PaginatedList(
github.ContentFile.ContentFile,
self.__requester,
"/search/code",
url_parameters
url_parameters,
headers=headers
)
def search_commits(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers):
"""
:calls: `GET /search/commits <http://developer.github.com/v3/search>`_