[Core] Add a language to every code block (#39212)
Co-authored-by: Peter Bengtsson <mail@peterbe.com>
This commit is contained in:
@@ -19,7 +19,7 @@ A bare term with no qualifiers will match either the content of a file or the fi
|
||||
|
||||
For example, the following query:
|
||||
|
||||
```
|
||||
```text
|
||||
http-push
|
||||
```
|
||||
|
||||
@@ -29,11 +29,11 @@ You can enter multiple terms separated by whitespace to search for documents tha
|
||||
|
||||
For example, the following query:
|
||||
|
||||
```
|
||||
```text
|
||||
sparse index
|
||||
```
|
||||
|
||||
The search results would include all documents containing both the terms `sparse` and `index`, in any order. As examples, it would match a file containing `SparseIndexVector`, a file with the phrase `index for sparse trees`, and even a file named `index.txt` that contains the term `sparse`.
|
||||
The search results would include all documents containing both the terms `sparse` and `index`, in any order. As examples, it would match a file containing `SparseIndexVector`, a file with the phrase `index for sparse trees`, and even a file named `index.txt` that contains the term `sparse`.
|
||||
|
||||
Searching for multiple terms separated by whitespace is the equivalent to the search `hello AND world`. Other boolean operations, such as `hello OR world`, are also supported. For more information about boolean operations, see "[Using boolean operations](#using-boolean-operations)."
|
||||
|
||||
@@ -47,19 +47,19 @@ You can also use regular expressions in your searches by surrounding the express
|
||||
|
||||
To search for an exact string, including whitespace, you can surround the string in quotes. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
"sparse index"
|
||||
```
|
||||
|
||||
To search for a phrase containing a quotation mark, you can escape the quotation mark using a backslash. For example, to find the exact string `name = "tensorflow"`, you can search:
|
||||
|
||||
```
|
||||
```text
|
||||
"name = \"tensorflow\""
|
||||
```
|
||||
|
||||
You can also use quoted strings in qualifiers, for example:
|
||||
|
||||
```
|
||||
```text
|
||||
path:git language:"protocol buffers"
|
||||
```
|
||||
|
||||
@@ -71,19 +71,19 @@ By default, adjacent terms separated by whitespace are equivalent to using the `
|
||||
|
||||
To search for documents containing either one term or the other, you can use the `OR` operator. For example, the following query will match documents containing either `sparse` or `index`:
|
||||
|
||||
```
|
||||
```text
|
||||
sparse OR index
|
||||
```
|
||||
|
||||
To exclude files from your search results, you can use the `NOT` operator. For example, to exclude files in the `__testing__` directory, you can search:
|
||||
|
||||
```
|
||||
```text
|
||||
"fatal error" NOT path:__testing__
|
||||
```
|
||||
|
||||
You can use parentheses to express more complicated boolean expressions. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
(language:ruby OR language:python) AND NOT path:"/tests/"
|
||||
```
|
||||
|
||||
@@ -102,13 +102,13 @@ You can use specialized keywords to qualify your search.
|
||||
|
||||
To search within a repository, use the `repo:` qualifier. You must provide the full repository name, including the owner. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
repo:github-linguist/linguist
|
||||
```
|
||||
|
||||
To search within a set of repositories, you can combine multiple `repo:` qualifiers with the boolean operator `OR`. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
repo:github-linguist/linguist OR repo:tree-sitter/tree-sitter
|
||||
```
|
||||
|
||||
@@ -122,13 +122,13 @@ repo:github-linguist/linguist OR repo:tree-sitter/tree-sitter
|
||||
|
||||
To search for files within an organization, use the `org:` qualifier. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
org:github
|
||||
```
|
||||
|
||||
To search for files within a personal account, use the `user:` qualifier. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
user:octocat
|
||||
```
|
||||
|
||||
@@ -142,7 +142,7 @@ user:octocat
|
||||
|
||||
To narrow down to a specific languages, use the `language:` qualifier. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
language:ruby OR language:cpp OR language:csharp
|
||||
```
|
||||
|
||||
@@ -152,7 +152,7 @@ For a complete list of supported language names, see [languages.yaml](https://gi
|
||||
|
||||
To search within file paths, use the `path:` qualifier. This will match files containing the term anywhere in their file path. For example, to find files containing the term `unit_tests` in their path, use:
|
||||
|
||||
```
|
||||
```text
|
||||
path:unit_tests
|
||||
```
|
||||
|
||||
@@ -160,7 +160,7 @@ The above query will match both `src/unit_tests/my_test.py` and `src/docs/unit_t
|
||||
|
||||
To match only a specific filename (and not part of the path), you could use a regular expression:
|
||||
|
||||
```
|
||||
```text
|
||||
path:/(^|\/)README\.md$/
|
||||
```
|
||||
|
||||
@@ -172,26 +172,26 @@ You can also use some limited glob expressions in the `path:` qualifier.
|
||||
|
||||
For example, to search for files with the extension `txt`, you can use:
|
||||
|
||||
```
|
||||
```text
|
||||
path:*.txt
|
||||
```
|
||||
|
||||
<br>
|
||||
To search for JavaScript files within a `src` directory, you could use:
|
||||
|
||||
```
|
||||
```text
|
||||
path:src/*.js
|
||||
```
|
||||
|
||||
- By default, glob expressions are not anchored to the start of the path, so the above expression would still match a path like `app/src/main.js`. But if you prefix the expression with `/`, it will anchor to the start. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
path:/src/*.js
|
||||
```
|
||||
|
||||
- Note that `*` doesn't match the `/` character, so for the above example, all results will be direct descendants of the `src` directory. To match within subdirectories, so that results include deeply nested files such as `/src/app/testing/utils/example.js`, you can use `**`. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
path:/src/**/*.js
|
||||
```
|
||||
|
||||
@@ -199,14 +199,14 @@ path:src/*.js
|
||||
|
||||
You can also use the `?` global character. For example, to match the path `file.aac` or `file.abc`, you can use:
|
||||
|
||||
```
|
||||
```text
|
||||
path:*.a?c
|
||||
```
|
||||
|
||||
<br>
|
||||
To search for a filename which contains a special character like `*` or `?`, just use a quoted string:
|
||||
|
||||
```
|
||||
```text
|
||||
path:"file?"
|
||||
```
|
||||
|
||||
@@ -218,7 +218,7 @@ You can search for symbol definitions in code, such as function or class definit
|
||||
|
||||
For example, to search for a symbol called `WithContext`:
|
||||
|
||||
```
|
||||
```text
|
||||
language:go symbol:WithContext
|
||||
```
|
||||
|
||||
@@ -226,7 +226,7 @@ In some languages, you can search for symbols using a prefix (e.g. a prefix of t
|
||||
|
||||
You can also use regular expressions with the symbol qualifier. For example, the following query would find conversions people have implemented in Rust for the `String` type:
|
||||
|
||||
```
|
||||
```text
|
||||
language:rust symbol:/^String::to_.*/
|
||||
```
|
||||
|
||||
@@ -249,7 +249,7 @@ We are working on adding support for more languages. If you would like to help c
|
||||
|
||||
By default, bare terms search both paths and file content. To restrict a search to strictly match the content of a file and not file paths, use the `content:` qualifier. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
content:README.md
|
||||
```
|
||||
|
||||
@@ -259,19 +259,19 @@ This query would only match files containing the term `README.md`, rather than m
|
||||
|
||||
To filter based on repository properties, you can use the `is:` qualifier. At this time, `is:` supports two values: `archived`, which restricts the search to archived repositories, and `fork`, which restricts the search to forked repositories. For example:
|
||||
|
||||
```
|
||||
```text
|
||||
path:/^MIT.txt$/ is:archived
|
||||
```
|
||||
|
||||
Note that the `is:` qualifier can be inverted with the `NOT` operator. To search for non-archived repositories, you can search:
|
||||
|
||||
```
|
||||
```text
|
||||
log4j NOT is:archived
|
||||
```
|
||||
|
||||
To exclude forks from your results, you can search:
|
||||
|
||||
```
|
||||
```text
|
||||
log4j NOT is:fork
|
||||
```
|
||||
|
||||
@@ -281,12 +281,12 @@ Code search supports regular expressions to search for patterns in your code. Yo
|
||||
|
||||
For example, to search for the regular expression `sparse.*index`, you would use:
|
||||
|
||||
```
|
||||
```text
|
||||
/sparse.*index/
|
||||
```
|
||||
|
||||
Note that you'll have to escape any forward slashes within the regular expression. For example, to search for files within the `App/src` directory, you would use:
|
||||
|
||||
```
|
||||
```text
|
||||
/^App\/src\//
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user