nodes: 0, module; 1, function_definition; 2, function_name:GenerateHelpText; 3, parameters; 4, block; 5, identifier:self; 6, identifier:env; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, function_definition; 11, expression_statement; 12, return_statement; 13, identifier:sort; 14, None; 15, comment:"""
          Generate the help text for the options.
  
          env - an environment that is used to get the current values
                of the options.
          cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1 
                or a boolean to indicate if it should be sorted.
          """; 16, call; 17, block; 18, elif_clause; 19, else_clause; 20, function_name:format; 21, parameters; 22, block; 23, assignment; 24, call; 25, identifier:callable; 26, argument_list; 27, expression_statement; 28, comparison_operator:sort is True; 29, block; 30, block; 31, identifier:opt; 32, default_parameter; 33, default_parameter; 34, if_statement; 35, return_statement; 36, identifier:lines; 37, list_comprehension; 38, attribute; 39, argument_list; 40, identifier:sort; 41, assignment; 42, identifier:sort; 43, True; 44, expression_statement; 45, expression_statement; 46, identifier:self; 47, identifier:self; 48, identifier:env; 49, identifier:env; 50, comparison_operator:opt.key in env; 51, block; 52, else_clause; 53, call; 54, identifier:_f; 55, for_in_clause; 56, if_clause; 57, string; 58, identifier:join; 59, identifier:lines; 60, identifier:options; 61, call; 62, assignment; 63, assignment; 64, attribute; 65, identifier:env; 66, expression_statement; 67, block; 68, attribute; 69, argument_list; 70, identifier:_f; 71, call; 72, identifier:_f; 73, identifier:sorted; 74, argument_list; 75, identifier:options; 76, call; 77, identifier:options; 78, attribute; 79, identifier:opt; 80, identifier:key; 81, assignment; 82, expression_statement; 83, identifier:self; 84, identifier:FormatVariableHelpText; 85, identifier:env; 86, attribute; 87, attribute; 88, attribute; 89, identifier:actual; 90, attribute; 91, identifier:map; 92, argument_list; 93, attribute; 94, keyword_argument; 95, identifier:sorted; 96, argument_list; 97, identifier:self; 98, identifier:options; 99, identifier:actual; 100, call; 101, assignment; 102, identifier:opt; 103, identifier:key; 104, identifier:opt; 105, identifier:help; 106, identifier:opt; 107, identifier:default; 108, identifier:opt; 109, identifier:aliases; 110, identifier:format; 111, identifier:options; 112, identifier:self; 113, identifier:options; 114, identifier:key; 115, call; 116, attribute; 117, keyword_argument; 118, attribute; 119, argument_list; 120, identifier:actual; 121, None; 122, identifier:cmp_to_key; 123, argument_list; 124, identifier:self; 125, identifier:options; 126, identifier:key; 127, lambda; 128, identifier:env; 129, identifier:subst; 130, binary_operator:'${%s}' % opt.key; 131, lambda; 132, lambda_parameters; 133, attribute; 134, string; 135, attribute; 136, lambda_parameters; 137, call; 138, identifier:x; 139, identifier:x; 140, identifier:key; 141, string_content:${%s}; 142, identifier:opt; 143, identifier:key; 144, identifier:x; 145, identifier:y; 146, identifier:sort; 147, argument_list; 148, attribute; 149, attribute; 150, identifier:x; 151, identifier:key; 152, identifier:y; 153, identifier:key
code: def GenerateHelpText(self, env, sort=None):
          """
          Generate the help text for the options.
  
          env - an environment that is used to get the current values
                of the options.
          cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1 
                or a boolean to indicate if it should be sorted.
          """
  
          if callable(sort):
              options = sorted(self.options, key=cmp_to_key(lambda x,y: sort(x.key,y.key)))
          elif sort is True:
              options = sorted(self.options, key=lambda x: x.key)
          else:
              options = self.options
  
          def format(opt, self=self, env=env):
              if opt.key in env:
                  actual = env.subst('${%s}' % opt.key)
              else:
                  actual = None
              return self.FormatVariableHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases)
          lines = [_f for _f in map(format, options) if _f]
  
          return ''.join(lines)