Add language param to highlight
The EE port is at https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7276
What does this MR do?
highlighting currently takes a repository
param. It is only used to read gitlab-language
from .gitattribute file in the repository.
This is inflexible since not all highlighting cases are associated with a repository. The concept of finding a repository file's language should really belong to the blob.
By replacing the repository
param with language
param, we can now
- save some CPU cycle for
rouge
to guess file type if we know that ahead of time. - makes caching more efficient, as forks of the same project can share highlighting the cache.
A BlobPresenter
is introduced to handle blob specific highlighting, DRYing repeated logic.
What the reviewer should watch out for
Blob
is the wrapper class for Gitlab::Git::Blob
, SnippetBlob
and Ci::ArtifactBlob
.
FoundBlob
is acting at the same level as Blob
, not being wrapped by it.
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides
Edited by Mark Chao