def getHtml(self, highlight=True): """Returns the comment text converted to HTML""" if self.variant == "doc" and self.__html is None: if markdown is None: raise JasyError("Markdown is not supported by the system. Documentation comments could not be processed into HTML.") self.__html = markdown(self.__originalText, highlight) return self.__html
def __init__(self, text, context=None, lineNo=0, indent="", fileId=None): # Store context (relation to code) self.context = context # Store fileId self.fileId = fileId # Convert if text.startswith("//"): # "// hello" => " hello" text = " " + text[2:] self.variant = "single" elif text.startswith("/**"): # "/** hello */" => " hello " text = " " + text[3:-2] self.variant = "doc" elif text.startswith("/*!"): # "/*! hello */" => " hello " text = " " + text[3:-2] self.variant = "protected" elif text.startswith("/*"): # "/* hello */" => " hello " text = " " + text[2:-2] self.variant = "multi" else: raise CommentException("Invalid comment text: %s" % text, lineNo) if "\n" in text: # Outdent indention text = self.__outdent(text, indent, lineNo) else: # Strip white space from single line comments # " hello " => "hello" text = text.strip() # Extract docs if self.variant == "doc": text = self.__processDoc(text, lineNo) html = text # Apply markdown convertion self.html = markdown(html) # Post process text to not contain any markup if "<" in text: text = stripMarkup.sub("", text) self.text = text
def getApi(self): field = "api[%s]" % self.id apidata = self.project.getCache().read(field, self.getModificationTime()) if markdown is None: raise JasyError("Missing Markdown feature to convert package docs into HTML.") if apidata is None: apidata = ApiData(self.id) apidata.main["type"] = "Package" apidata.main["doc"] = markdown(self.getText()) self.project.getCache().store(field, apidata, self.getModificationTime()) return apidata