pygments-custom-lexer-apexΒΆ

Uses pygments-lexer-apex (GitHub) package to colorize Salesforce Apex language.

Including FundController.apxc should show this file properly colorized by pygments.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
GLOBAL with sharing class FundController {

    public class PagedResult {

        @AuraEnabled
        public Integer pageSize { get;set; }

        @AuraEnabled
        public Integer page { get;set; }

        @AuraEnabled
        public Integer total { get;set; }

        @AuraEnabled
        public List<Fund__c> funds { get;set; }

    }

    public class Filter {

        @AuraEnabled
        public String searchKey { get;set; }

        @AuraEnabled
        public String assetClass { get;set; }

        @AuraEnabled
        public String sector { get;set; }

        @AuraEnabled
        public Decimal minYtdReturn { get;set; }

        @AuraEnabled
        public Decimal maxYtdReturn { get;set; }

        @AuraEnabled
        public Decimal min1YearReturn { get;set; }

        @AuraEnabled
        public Decimal max1YearReturn { get;set; }

        @AuraEnabled
        public Decimal min5YearReturn { get;set; }

        @AuraEnabled
        public Decimal max5YearReturn { get;set; }
    }

    @AuraEnabled
    public static PagedResult getFunds(String filters, Decimal pageSize, Decimal pageNumber) {
        Filter filter = (Filter) JSON.deserializeStrict(filters, FundController.Filter.class);
        Integer pSize = (Integer)pageSize;
        String key = '%' + filter.searchKey + '%';
        Integer offset = ((Integer)pageNumber - 1) * pSize;
        PagedResult r =  new PagedResult();
        DELETe r;
        r.pageSize = pSize;
        r.page = (Integer) pageNumber;
        r.total = [SELECT count() FROM Fund__c
                   WHERE name LIKE :key
                   AND Asset_Class__c like : (filter.assetClass == '' ? '%' : filter.assetClass)
                   AND Sector__r.Name like : (filter.sector == '' ? '%' : filter.sector)
                   AND YTD_Return__c >= :filter.minYtdReturn AND YTD_Return__c <= :filter.maxYtdReturn
                   AND One_Year_Return__c >= :filter.min1YearReturn AND One_Year_Return__c <= :filter.max1YearReturn
                   AND Five_Year_Return__c >= :filter.min5YearReturn AND Five_Year_Return__c <= :filter.max5YearReturn
                  ];
        r.funds = [SELECT id, name, abbreviation__c, asset_class__c, sector__r.Name, rating__c, YTD_Return__c, One_Year_Return__c, Two_Year_Return__c, Five_Year_Return__c FROM Fund__c
                   WHERE name LIKE :key
                   AND Asset_Class__c like : (filter.assetClass == '' ? '%' : filter.assetClass)
                   AND Sector__r.Name like : (filter.sector == '' ? '%' : filter.sector)
                   AND YTD_Return__c >= :filter.minYtdReturn AND YTD_Return__c <= :filter.maxYtdReturn
                   AND One_Year_Return__c >= :filter.min1YearReturn AND One_Year_Return__c <= :filter.max1YearReturn
                   AND Five_Year_Return__c >= :filter.min5YearReturn AND Five_Year_Return__c <= :filter.max5YearReturn
                   LIMIT :pSize OFFSET :offset];
        return r;
    }

    @AuraEnabled
    public static List<String> getAssetClasses() {
        Schema.DescribeFieldResult result = Fund__c.Asset_Class__c.getDescribe();
        List<Schema.PicklistEntry> entries = result.getPicklistValues();
        List<String> values = new list <String>();
        for (Schema.PicklistEntry entry: entries) {
            values.add(entry.getValue());
        }
        return values;
    }

    @AuraEnabled
    public static Sector__c[] getSectors() {
        return [SELECT Id, Name FROM Sector__c ORDER BY Name];
    }

}

requirements.txt file to install the lexer:

1
2
3
sphinx-autorun

git+https://github.com/shawalli/pygments-lexer-apex.git#egg=pygments-lexer-apex

Sphinx configuration file to build this docs (see full file),

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# -*- coding: utf-8 -*-

# Default settings
project = 'Test Builds'
extensions = [
    'sphinx_autorun',
]

# Include all your settings here
html_theme = 'sphinx_rtd_theme'






>>> # Build at
>>> import datetime
>>> datetime.datetime.utcnow()  # UTC
datetime.datetime(2019, 3, 24, 1, 48, 44, 366894)