### Example Commands Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/scopes/raw/test.md Example commands for GDK. ```sh gdk reconfigure gdk restart ``` -------------------------------- ### Configuration Examples Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/checks/Spelling/test.md Examples of external URL and GitLab host configuration. ```ruby external_url "https://gitlab.example.com" ``` ```yaml gitlab: host: "gitlab.example.com" ``` -------------------------------- ### script.py Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test.org An example Python script excerpt. ```python This is some text ACT test ``` -------------------------------- ### Continuous Integration Setup with Travis CI Source: https://github.com/vale-cli/vale/wiki/Use-Cases Example Travis CI configuration to set up Vale for checking documentation style on every commit. ```yaml # .travis.yml language: go install: - go get github.com/jdkato/vale script: - vale docs/ ``` -------------------------------- ### Slicing Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Shows how slicing works with lists, including start and end indices. ```python >>> sent[5:8] ['word6', 'word7', 'word8'] >>> sent[5] 'word6' >>> sent[6] 'word7' >>> sent[7] 'word8' ``` ```python >>> sent[:3] # [_slice2] ['word1', 'word2', 'word3'] ``` ```python >>> text2[141525:] # [_slice3] ['among', 'the', 'merits', 'and', 'the', 'happiness', 'of', 'Elinor', 'and', 'Marianne', ',', 'let', 'it', 'not', 'be', 'ranked', 'as', 'the', 'least', 'considerable', ',', 'that', 'though', 'sisters', ',', 'and', 'living', 'almost', 'within', 'sight', 'of', 'each', 'other', ',', 'they', 'could', 'live', 'without', 'disagreement', 'between', 'themselves', ',', 'or', 'producing', 'coolness', 'between', 'their', 'husbands', '.', 'THE', 'END'] ``` -------------------------------- ### Deployment YAML Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/comments/test.md An example of a Kubernetes Service and Deployment configuration in YAML format. ```yaml apiVersion: v1 kind: Service metadata: name: my-nginx-svc labels: app: nginx spec: type: LoadBalancer ports: - port: 80 selector: app: nginx --- apiVersion: apps/v1 kind: Deployment metadata: name: my-nginx labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 ``` -------------------------------- ### Installing Vale with Go Source: https://github.com/vale-cli/vale/wiki/Home Instructions for installing the Vale executable using the Go programming language's package management. ```bash $ go get github.com/ValeLint/vale ``` -------------------------------- ### Interactive Translation Party Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst An example of how to try machine translation yourself using an online tool. ```text .. note:: |TRY| Try this yourself using ``http://translationparty.com/`` ``` -------------------------------- ### Example Code Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/formats/test.mdx Demonstrates component usage, imports, and inline JavaScript. ```javascript import {External} from './some/place.js' import {Chart} from './chart.js' import population from './population.js' import XXX from './XXX.js' export const TODO = 3.14 export const Local = properties => An XXX component and a local one TODO. TODO: You can also use objects with components, such as the `TODO` component on the `myComponents` object: } /> Two 🍰 is: {Math.PI * 2}, TODO {(function () { const TODO = Math.random() if (guess > 0.66) { return Look at us. } if (guess > 0.33) { return Who would have guessed?! } return Not me. })()} ``` -------------------------------- ### Example Configuration for Python and reStructuredText Source: https://github.com/vale-cli/vale/wiki/Configuration An example configuration file demonstrating how to specify styles for different file types, specifically Python and reStructuredText. ```ini StylesPath = styles [*.{rst,py}] BasedOnStyles = base, ProjectName ``` -------------------------------- ### NLTK book import and example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Imports NLTK books and provides an example of processing a list of words. ```python >>> from nltk.book import * ``` ```python >>> saying = ['After', 'all', 'is', 'said', 'and', 'done', ... 'more', 'is', 'said', 'than', 'done'] >>> tokens = set(saying) >>> tokens = sorted(tokens) >>> tokens[-2:] what output do you expect here? >>> ``` -------------------------------- ### Example Sentences Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Shows example sentences defined as lists of words. ```python >>> sent2 ['The', 'family', 'of', 'Dashwood', 'had', 'long', 'been', 'settled', 'in', 'Sussex', '.'] >>> sent3 ['In', 'the', 'beginning', 'God', 'created', 'the', 'heaven', 'and', 'the', 'earth', '.'] >>> ``` -------------------------------- ### Deployment YAML Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/comments/test.mdx An example of a deployment.yaml file. ```yaml apiVersion: v1 kind: Service metadata: name: my-nginx-svc labels: app: nginx spec: type: LoadBalancer ports: - port: 80 selector: app: nginx --- apiVersion: apps/v1 kind: Deployment metadata: name: my-nginx labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 ``` -------------------------------- ### Example Configuration with Style Overrides for reStructuredText and Python Source: https://github.com/vale-cli/vale/wiki/Configuration This example shows how to apply different style configurations for reStructuredText and Python files, including the addition of a 'docs' style for reStructuredText and enabling a specific rule. ```ini [*.rst] BasedOnStyles = base, ProjectName, docs [*.py] BasedOnStyles = base, ProjectName docs.SomeRule = YES # there's actually one rule we want ``` -------------------------------- ### Example Style Directory Structure Source: https://github.com/vale-cli/vale/wiki/Styles An example of how a project's style directory might be structured, with different styles like 'base', 'blog', and 'docs' containing individual rule definitions. ```text styles/ ├── base/ │ ├── ComplexWords.yml │ ├── SentenceLength.yml │ ... ├── blog/ │ ├── TechTerms.yml │ ... └── docs/ ├── Branding.yml ... ``` -------------------------------- ### Example command Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/checks/Repetition/text.rst An example command that might be used in a terminal. ```bash user@foo# show bar bar monitor http server-app4_10.128.10.240_8080 { ``` -------------------------------- ### Substitution Check Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of a 'substitution' check configuration in YAML, used to suggest replacing one string with another. ```yaml type: substitution message: Consider using '%s' instead of '%s' ignorecase: true level: warning swap: abundance: plenty accelerate: speed up ``` -------------------------------- ### Consistency Check Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of a 'consistency' check configuration in YAML, ensuring that a key and its value do not both appear within the same scope. ```yaml type: consistency message: "Inconsistent spelling of '%s'" level: warning scope: text ignorecase: true either: advisor: adviser centre: center ``` -------------------------------- ### Existence Check Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of an 'existence' check configuration in YAML, used to find specific strings. ```yaml type: existence message: "Consider removing '%s'" ignorecase: true level: warning tokens: - appear to be - arguably ``` -------------------------------- ### Variable Assignment Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates defining variables and assigning expressions to them. ```python >>> sent1 = ['Call', 'me', 'Ishmael', '.'] ``` ```python >>> my_sent = ['Bravely', 'bold', 'Sir', 'Robin', ',', 'rode', ... 'forth', 'from', 'Camelot', '.'] >>> noun_phrase = my_sent[1:4] >>> noun_phrase ['bold', 'Sir', 'Robin'] >>> wOrDs = sorted(noun_phrase) >>> wOrDs ['Robin', 'Sir', 'bold'] ``` -------------------------------- ### HTML Include Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test.rst An example HTML include with conditional logic. ```html {% if page.mathjax %} {% ACT test %} {{< /file-excerpt >}} ``` -------------------------------- ### Example Text-Hypothesis Pair Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst An example illustrating a text and a hypothesis used in evaluating natural language understanding systems. ```text Text: David Golinkin is the editor or author of eighteen books, and over 150 responsa, articles, sermons and books Hypothesis: Golinkin has written eighteen books ``` -------------------------------- ### For Loop Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates a basic for loop to iterate over a list and print each item. ```Python >>> for word in ['Call', 'me', 'Ishmael', '.']: ... print(word) ... Call me Ishmael . >>> ``` -------------------------------- ### Calling a Function Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Examples of calling Python functions with and without arguments. ```python texts() ``` ```python mult(3, 4) ``` ```python len(text1) ``` -------------------------------- ### Defining Button Locations Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test4.html Example of how to define button locations in Mautic's UI. ```php ' ."\n"; $dropdownOpenHtml .= ''); ``` -------------------------------- ### Defining Button Locations Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test2.rst Example of how to define button locations using PHP, including rendering buttons with a dropdown. ```php ' ."\n"; $dropdownOpenHtml .= ''); ``` -------------------------------- ### Existence Check with Raw Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of an 'existence' check using the 'raw' key, where elements are concatenated to form a regular expression. ```yaml raw: - '(?:foo)\sbar' - '(baz)' ``` -------------------------------- ### NLTK Chatbot Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst An example of how to access and use primitive dialogue systems (chatbots) within the NLTK library. ```python nltk.chat.chatbots() (Remember to ``import nltk`` first.) ``` -------------------------------- ### Existence Check with Tokens Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of an 'existence' check using the 'tokens' key to define strings to search for, which are converted into a word-bounded group. ```yaml message: "Consider removing '%s'" tokens: - foo - bar - baz ``` -------------------------------- ### String Slicing Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates string slicing to extract a portion of a string. ```Python "Monty Python"[6:12] ``` -------------------------------- ### HTML File Excerpt with Script Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test.md An example of an HTML file excerpt including a script tag and a placeholder. ```html {% ACT test %} ``` -------------------------------- ### SSH Container Security Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/comments/test.mdx Example command related to SSH security in containers. ```bash SSH should not typically be used within containers. Ensure that non-SSH services are not using port 22. ``` -------------------------------- ### Intermediate variable example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Shows how to use intermediate variables to make code easier to follow. ```python >>> vocab = set(text1) >>> vocab_size = len(vocab) >>> vocab_size 19317 >>> ``` -------------------------------- ### List Indexing Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates list indexing to access an element at a specific position. ```Python ["Monty", "Python"][1] ``` -------------------------------- ### Go function example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.md A Go function to extract syntax from a name. ```go // XXX: fix this relatively soon. func ExtFromSyntax(name string) string { for XXX, relatively := range LookupSyntaxName { if matched, _ := regexp.MatchString(r, name); matched { return s } } return name } ``` -------------------------------- ### Repetition Check Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of a 'repetition' check configuration in YAML, used to detect repeated occurrences of specified tokens within a scope. ```yaml type: repetition message: "'%s' is repeated!" level: error scope: paragraph ignorecase: true tokens: - '\b(\w+)\b' ``` -------------------------------- ### Importing NLTK Books Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Imports necessary components from NLTK for further examples. ```python >>> from nltk.book import * >>> ``` -------------------------------- ### ES5 Getter/Setter Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md Demonstrates the use of getter and setter literal forms in ES5. ```javascript var o = { __id: 10, get id() { return this.__id++; }, set id(v) { this.__id = v; } } o.id; // 10 o.id; // 11 o.id = 20; o.id; // 20 // and: o.__id; // 21 o.__id; // 21 -- still! ``` -------------------------------- ### List Comprehension Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates a Python list comprehension for transforming elements of a list. ```Python >>> len(text1) 260819 >>> len(set(text1)) 19317 >>> len(set(word.lower() for word in text1)) 17231 >>> >>> len(set(word.lower() for word in text1 if word.isalpha())) 16948 >>> ``` -------------------------------- ### Configuration for Client-Specific Rules Source: https://github.com/vale-cli/vale/wiki/Use-Cases Example configuration snippet showing how to specify client-specific styles in Vale. ```ini [*.{md,txt}] BasedOnStyles = MainStyleGuide, client1 ``` -------------------------------- ### Example: Question Answering Application Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Shows a question-answering scenario where the machine correctly identifies what was sold based on pronoun resolution. ```rst .. ex:: .. ex:: *Text:* ... The thieves stole the paintings. They were subsequently sold. ... .. ex:: *Human:* Who or what was sold? .. ex:: *Machine:* The paintings. ``` -------------------------------- ### Sample Asciidoc Code Block 1 Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/formats/adoc/test2.adoc An example of an Asciidoc code block. ```asciidoc some asciidoc ``` -------------------------------- ### Tessera JDBC Configuration Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/misc/infostring/test.md Example JSON configuration for Tessera's JDBC settings, including encrypted password. ```json "jdbc": { "username": "sa", "password": "ENC(ujMeokIQ9UFHSuBYetfRjQTpZASgaua3)", "url": "jdbc:h2:/qdata/c1/db1", "autoCreateTables": true } ``` -------------------------------- ### Configuration object with some defaults applied Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md An example of a configuration object that has some defaults applied. ```javascript var config = { options: { remove: false, instance: null } }; ``` -------------------------------- ### ButtonSubscriber.php Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/patterns/test2.rst Example of a PHP subscriber class that injects custom buttons into Mautic's UI. ```php ['injectViewButtons', 0] ]; } /** * @param CustomButtonEvent $event */ public function injectViewButtons(CustomButtonEvent $event) { // Injects a button into the toolbar area for any page with a high priority (displays closer to first) $event->addButton( [ 'attr' => [ 'class' => 'btn btn-default btn-sm btn-nospin', 'data-toggle' => 'ajaxmodal', 'data-target' => '#MauticSharedModal', 'href' => $this->router->generate('mautic_world_action', ['objectAction' => 'doSomething']), 'data-header' => 'Extra Button', ], 'tooltip' => $this->translator->trans('mautic.world.dosomething.btn.tooltip'), 'iconClass' => 'fa fa-star', 'priority' => 255, ], ButtonHelper::LOCATION_TOOLBAR_ACTIONS ); // if ($lead = $event->getItem()) { if ($lead instanceof Lead) { $sendEmailButton = [ 'attr' => [ 'data-toggle' => 'ajaxmodal', 'data-target' => '#MauticSharedModal', 'data-header' => $this->translator->trans( 'mautic.world.dosomething.header', ['%email%' => $event->getItem()->getEmail()] ), 'href' => $this->router->generate( 'mautic_world_action', ['objectId' => $event->getItem()->getId(), 'objectAction' => 'doSomething'] ), ], 'btnText' => 'Extra Button', 'iconClass' => 'fa fa-star', 'primary' => true, 'priority' => 255, ]; // Inject a button into the page actions for the specified route (in this case /s/contacts/view/{contactId}) $event ->addButton( $sendEmailButton, // Location of where to inject the button; this can be an array of multiple locations ButtonHelper::LOCATION_PAGE_ACTIONS, ['mautic_contact_action', ['objectAction' => 'view']] ) // Inject a button into the list actions for each contact on the /s/contacts page ->addButton( $sendEmailButton, ButtonHelper::LOCATION_LIST_ACTIONS, 'mautic_contact_index' ); } } } } ``` -------------------------------- ### String manipulation examples Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Illustrates basic string operations like assignment, indexing, slicing, multiplication, addition, joining, and splitting. ```python >>> name = 'Monty' # [_assign-string] >>> name[0] # [_index-string] 'M' >>> name[:4] # [_slice-string] 'Mont' >>> ``` ```python >>> name * 2 'MontyMonty' >>> name + '!' 'Monty!' >>> ``` ```python >>> ' '.join(['Monty', 'Python']) 'Monty Python' >>> 'Monty Python'.split() ['Monty', 'Python'] >>> ``` -------------------------------- ### Client-Specific Rules Directory Structure Source: https://github.com/vale-cli/vale/wiki/Use-Cases Example directory structure for organizing client-specific style rules. ```text styles/ ├── client1/ │ ... ├── client2/ │ ... ``` -------------------------------- ### Finding Four-Letter Words with FreqDist Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Example of finding four-letter words and showing them by frequency using FreqDist. ```Python FreqDist ``` -------------------------------- ### Computed Property Names Example (Pre-ES6) Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md Illustrates a common scenario before ES6 where property names are dynamic. ```javascript var prefix = "user_"; var o = { baz: function(..){ .. } }; o[ prefix + "foo" ] = function(..){ .. }; o[ prefix + "bar" ] = function(..){ .. }; .. ``` -------------------------------- ### Example: Pronoun Resolution Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates pronoun resolution by identifying the antecedent of 'they' in sentences about thieves and paintings. ```rst .. ex:: .. ex:: The thieves stole the paintings. They were subsequently `sold`:em:. .. ex:: The thieves stole the paintings. They were subsequently `caught`:em:. .. ex:: The thieves stole the paintings. They were subsequently `found`:em:. ``` -------------------------------- ### External URL example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.md Example of an external URL definition. ```hcl external_url "https://TODO.example.com" ``` -------------------------------- ### Example: Machine Translation Application Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Illustrates machine translation challenges, specifically the need to choose gendered pronouns based on understanding the antecedent. ```rst .. ex:: .. ex:: The thieves stole the paintings. They were subsequently found. .. ex:: Les voleurs ont vol\ |eacute| les peintures. Ils ont |eacute|t\ |eacute| trouv\ |eacute|s plus tard. (the thieves) .. ex:: Les voleurs ont vol\ |eacute| les peintures. Elles ont |eacute|t\ |eacute| trouv\ |eacute|es plus tard. (the paintings) ``` -------------------------------- ### Verifying Downloads with GPG Source: https://github.com/vale-cli/vale/wiki/Home Instructions on how to verify downloaded Vale releases using GPG, including importing the public key and verifying the signature. ```bash # after downloading my public key, we need to import it $ gpg --import jdkato_gpg_key.asc # verify the signature (replace "macOS-64bit.tar.gz" with your download if necessary) $ gpg --verify macOS-64bit.tar.gz.asc macOS-64bit.tar.gz ``` -------------------------------- ### Machine Translation Round Trip Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates a machine translation round trip (English to German and back) showing how meaning can degrade over multiple translations. ```text | 0> how long before the next flight to Alice Springs? | 1> wie lang vor dem folgenden Flug zu Alice Springs? | 2> how long before the following flight to Alice jump? | 3> wie lang vor dem folgenden Flug zu Alice springen Sie? | 4> how long before the following flight to Alice do you jump? | 5> wie lang, bevor der folgende Flug zu Alice tun, Sie springen? | 6> how long, before the following flight to Alice does, do you jump? | 7> wie lang bevor der folgende Flug zu Alice tut, tun Sie springen? | 8> how long before the following flight to Alice does, do you jump? | 9> wie lang, bevor der folgende Flug zu Alice tut, tun Sie springen? | 10> how long, before the following flight does to Alice, do do you jump? | 11> wie lang bevor der folgende Flug zu Alice tut, Sie tun Sprung? | 12> how long before the following flight does leap to Alice, does you? ``` -------------------------------- ### Substring Assignment Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/spellingv3/test.rst Example demonstrating how a substring assignment influences values. ```Java s2 = s1.substring(i) ``` -------------------------------- ### Python for-loops Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/styles/demo/test.md Demonstrates the correct way to refer to Python for-loops. ```text Python has for-loops (not `for` loops or for loops). ``` -------------------------------- ### Example Protected Branch Response Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/misc/markup/test.md Example JSON response for a protected branch. ```json { "id": 1, "name": "*-stable", "push_access_levels": [ { "access_level": null, "user_id": 1, "group_id": null, "access_level_description": "Administrator" } ], "merge_access_levels": [ { "access_level": 40, "user_id": null, "group_id": null, "access_level_description": "Maintainers" } ], "unprotect_access_levels": [ { "access_level": 40, "user_id": null, "group_id": null, "access_level_description": "Maintainers" } ], "code_owner_approval_required": "false" } ``` -------------------------------- ### bash Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.rst A MacPorts *port* is also available: ```bash $ brew install very ``` -------------------------------- ### c Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.rst printf("%s", "TODO") // TODO: ```c printf("%s", "TODO") // TODO: ``` -------------------------------- ### python Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.rst A MacPorts *port* is also available: ```python def foo(): """ NOTE: this is a very important function. """ obviously = False very = True return very and obviously ``` -------------------------------- ### Vale CLI Output Example Source: https://github.com/vale-cli/vale/wiki/Styles Example of the output generated by Vale CLI when running a conditional check on a text that violates the rule. ```text test.md:1:224:vale.UnexpandedAcronyms:'DAFB' has no definition ``` -------------------------------- ### Word Lengths and Frequency Distribution Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates calculating word lengths and creating a frequency distribution from them. ```python >>> [len(w) for w in text1] # [_word-lengths] [1, 4, 4, 2, 6, 8, 4, 1, 9, 1, 1, 8, 2, 1, 4, 11, 5, 2, 1, 7, 6, 1, 3, 4, 5, 2, ...] >>> fdist = FreqDist(len(w) for w in text1) # [_freq-word-lengths] >>> print(fdist) # [_freq-word-lengths-size] >>> fdist FreqDist({3: 50223, 1: 47933, 4: 42345, 2: 38513, 5: 26597, 6: 17111, 7: 14399, 8: 9966, 9: 6428, 10: 3528, ...}) >>> ``` ```python >>> fdist.most_common() [(3, 50223), (1, 47933), (4, 42345), (2, 38513), (5, 26597), (6, 17111), (7, 14399), (8, 9966), (9, 6428), (10, 3528), (11, 1873), (12, 1053), (13, 567), (14, 177), (15, 70), (16, 22), (17, 12), (18, 1), (20, 1)] >>> fdist.max() 3 >>> fdist[3] 50223 >>> fdist.freq(3) 0.19255882431878046 >>> ``` -------------------------------- ### Occurrence Check Example Source: https://github.com/vale-cli/vale/wiki/Styles An example of an 'occurrence' check configuration in YAML, limiting the number of times a token can appear within a scope, such as limiting words per sentence. ```yaml message: "Sentences should be less than 25 words" type: occurrence scope: sentence level: suggestion max: 25 token: '\b(\w+)\b' ``` -------------------------------- ### Pre-ES6 code example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md An example of pre-ES6 code that uses a named function expression within an object literal, allowing for recursion. ```javascript function runSomething(o) { var x = Math.random(), y = Math.random(); return o.something( x, y ); } runSomething( { something: function something(x,y) { if (x > y) { // recursively call with `x` // and `y` swapped return something( y, x ); } return y - x; } } ); ``` -------------------------------- ### Complex Default Value Assignment Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md A complex example demonstrating default value assignment with nested objects, highlighting potential for confusion. ```javascript var x = 200, y = 300, z = 100; var o1 = { x: { y: 42 }, z: { y: z } }; ( { y: x = { y: y } } = o1 ); ( { z: y = { y: z } } = o1 ); ( { x: z = { y: x } } = o1 ); console.log( x.y, y.y, z.y ); // 300 100 42 ``` -------------------------------- ### Creating a Symbol Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.md Demonstrates how to create a symbol and check its type. ```javascript var sym = Symbol( "some optional description" ); typeof sym; // "symbol" ``` -------------------------------- ### Python function example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.md A simple Python function definition. ```python def foo(): """ NOTE: this is a very important function. """ obviously = False very = True return very and obviously ``` -------------------------------- ### IndexError Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates an IndexError when accessing an index out of range. ```python >>> sent[10] IndexError: list index out of range ``` -------------------------------- ### pwsh Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.rst & TODO ```pwsh & TODO ``` -------------------------------- ### Substitution Check with Regular Expression Keys Source: https://github.com/vale-cli/vale/wiki/Styles An example demonstrating that keys in a 'substitution' check's 'swap' can be regular expressions, with a note on avoiding nested capture groups. ```yaml swap: '(?:give|gave) rise to': lead to # this is okay '(give|gave) rise to': lead to # this is bad! ``` -------------------------------- ### String Definition and Printing Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates defining a string and printing its contents in two ways. ```python my_string = 'My String' print(my_string) ``` -------------------------------- ### Python Interpreter as a Calculator Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates using the Python interpreter for basic arithmetic operations. ```python 12 / (4 + 1) ``` -------------------------------- ### Frequency Distribution of Moby Dick Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates how to create a frequency distribution from a text and inspect its properties, including finding the most common words. ```Python >>> fdist1 = FreqDist(text1) # [_freq-dist-call] >>> print(fdist1) # [_freq-dist-inspect] >>> fdist1.most_common(50) # [_freq-dist-most-common] [(',', 18713), ('the', 13721), ('.', 6862), ('of', 6536), ('and', 6024), ('a', 4569), ('to', 4542), (';', 4072), ('in', 3916), ('that', 2982), ("'", 2684), ('-', 2552), ('his', 2459), ('it', 2209), ('I', 2124), ('s', 1739), ('is', 1695), ('he', 1661), ('with', 1659), ('was', 1632), ('as', 1620), ('"', 1478), ('all', 1462), ('for', 1414), ('this', 1280), ('!', 1269), ('at', 1231), ('by', 1137), ('but', 1113), ('not', 1103), ('--', 1070), ('him', 1058), ('from', 1052), ('be', 1030), ('on', 1005), ('so', 918), ('whale', 906), ('one', 889), ('you', 841), ('had', 767), ('have', 760), ('there', 715), ('But', 705), ('or', 697), ('were', 680), ('now', 646), ('which', 640), ('?', 637), ('me', 627), ('like', 624)] >>> fdist1['whale'] 906 >>> ``` -------------------------------- ### List to String Conversion and Splitting Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates converting a list of words to a string and splitting a string back into a list. ```python my_sent = ["My", "sent"] ' '.join(my_sent) split() ``` -------------------------------- ### mostRecentMessages-Response (JSON) Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test3.mdx Example JSON response for fetching recent messages. ```json { "request_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "data": [ { "id": "msg-1", "thread_id": "thr-1", "subject": "Meeting Reminder", "from": [ { "name": "Alice", "email": "alice@example.com" } ], "to": [ { "name": "Bob", "email": "bob@example.com" } ], "date": 1678886400, "body": { "text": "Hi Bob, Just a reminder about our meeting tomorrow at 10 AM.", "html": "

Hi Bob,

Just a reminder about our meeting tomorrow at 10 AM.

" }, "attachments": [], "folders": ["inbox"], "unread": true, "starred": false, "snippet": "Hi Bob, Just a reminder about our meeting tomorrow at 10 AM." } ], "next_cursor": null } ``` -------------------------------- ### Range Function Examples Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Illustrates various uses of the built-in range() function in Python. ```Python list(range(10)) ``` ```Python list(range(10, 20)) ``` ```Python list(range(10, 20, 2)) ``` ```Python list(range(20, 10, -2)) ``` -------------------------------- ### go Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/frontmatter/test.rst Here is another interesting codeblock: ```go // XXX: fix this relatively soon. func ExtFromSyntax(name string) string { for XXX, relatively := range LookupSyntaxName { if matched, _ := regexp.MatchString(r, name); matched { return s } } return name } ``` -------------------------------- ### List Modification Example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Illustrates modifying list elements by index and replacing slices. ```python >>> sent[0] = 'First' # [_list-assignment] >>> sent[9] = 'Last' >>> len(sent) 10 >>> sent[1:9] = ['Second', 'Third'] # [_slice-assignment] >>> sent ['First', 'Second', 'Third', 'Last'] >>> sent[9] # [_list-error] Traceback (most recent call last): File "", line 1, in ? IndexError: list index out of range ``` -------------------------------- ### Finding Word Index Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Example of using the index() method to find the position of a word in a text. ```Python text9.index('sunset') ``` -------------------------------- ### Calling lexical_diversity and percentage functions Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates how to call the previously defined lexical_diversity and percentage functions with different arguments. ```python >>> lexical_diversity(text3) 0.06230453042623537 >>> lexical_diversity(text5) 0.13477005109975562 >>> percentage(4, 5) 80.0 >>> percentage(text4.count('a'), len(text4)) 1.4643016433938312 >>> ``` -------------------------------- ### Similar words in context Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates finding words that appear in similar contexts within a text. ```python >>> text1.similar("monstrous") mean part maddens doleful gamesome subtly uncommon careful untoward exasperate loving passing mouldy christian few true mystifying imperial modifies contemptible >>> text2.similar("monstrous") very heartily so exceedingly remarkably as vast a great amazingly extremely good sweet >>> ``` -------------------------------- ### Python syntax error example Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Demonstrates a SyntaxError when trying to use a reserved Python keyword as a variable name. ```python >>> not = 'Camelot' # doctest: +SKIP File "", line 1 not = 'Camelot' ^ SyntaxError: invalid syntax >>> ``` -------------------------------- ### Iterating Through Text Source: https://github.com/vale-cli/vale/blob/v3/testdata/fixtures/benchmarks/bench.rst Python code demonstrating how to process each word in a text using a for loop. ```python for w in t: ``` ```python for word in text: ```