summary refs log tree commit diff stats
path: root/nimdoc/testproject/subdir/subdir_b
Commit message (Collapse)AuthorAgeFilesLines
* Fix nim doc crash with group referencing & include (#21600)Andrey Makarov2023-04-021-0/+5
| | | | | | | This fixes a regression introduced in #20990 . When a group referencing is used and one of the overloaded symbols is in `include`d file, then `nim doc` crashes. The fix is in distinguishing (the index of) module and file where the symbol is defined, and using only module as the key in hash table for group referencing.
* Implement Pandoc Markdown concise link extension (#20304)Andrey Makarov2022-09-041-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement Pandoc Markdown concise link extension This implements https://github.com/nim-lang/Nim/issues/20127. Besides reference to headings we also support doing references to Nim symbols inside Nim modules. Markdown: ``` Some heading ------------ Ref. [Some heading]. ``` Nim: ``` proc someFunction*() ... ... ## Ref. [someFunction] ``` This is substitution for RST syntax like `` `target`_ ``. All 3 syntax variants of extension from Pandoc Markdown are supported: `[target]`, `[target][]`, `[description][target]`. This PR also fixes clashes in existing files, particularly conflicts with RST footnote feature, which does not work with this PR (but there is a plan to adopt a popular [Markdown footnote extension](https://pandoc.org/MANUAL.html#footnotes) to make footnotes work). Also the PR fixes a bug that Markdown links did not work when `[...]` section had a line break. The implementation is straightforward since link resolution did not change w.r.t. RST implementation, it's almost only about new syntax addition. The only essential difference is a possibility to add a custom link description: form `[description][target]` which does not have an RST equivalent. * fix nim 1.0 gotcha
* Fix group reference (with capital letters (#19196)Andrey Makarov2021-12-201-0/+6
| | | in group name)
* docgen: implement doc link resolution in current module (#18642)Andrey Makarov2021-10-283-0/+74
|
* support same-line doc comments in routines (#18595)Timothee Cour2021-07-271-0/+17
| | | | * support same-line comments in routines * remove assert as per review comment
* fix #16993, #18054, #17835 runnableExamples now works with templates and ↵Timothee Cour2021-06-021-3/+7
| | | | nested templates (#18082)
* cleanup comment now that #14434 was fixed (#14874)Timothee Cour2020-07-011-2/+0
|
* fix #8871 runnableExamples now preserves source code comments, litterals, ↵Timothee Cour2020-05-281-0/+22
| | | | | | | | | | | and all formatting; other bug fix (#14439) * fix #8871 runnableExamples now preserves source code comments, litterals, and all formatting * remove orig deadcode from getAllRunnableExamplesImpl * fix expected examples * add test to close https://github.com/nim-lang/Nim/issues/14473 * correctly handle regular comments before 1st token inside runnableExamples * add test to answer https://github.com/nim-lang/Nim/pull/14439#discussion_r431829199 * update tests
* RST parser: fixes #8158Araq2019-01-111-0/+9
|
* docgen: support markdown headings tooAraq2019-01-111-0/+13
|
* docgen: support markdown link syntax; enable markdown extensionsAraq2019-01-111-0/+2
|
* docgen: fixes #9432 [backport]Araq2018-10-311-0/+16
|
* index generation for docgen knows about subdirectories; index knows about ↵Araq2018-09-131-1/+4
| | | | enum values; fixes import statement for runnableExamples
* added a test for 'nim doc'Andreas Rumpf2018-09-071-0/+7
"""Bookmarks is a container which associates keys with bookmarks. A key is a string with: len(key) == 1 and key in ALLOWED_KEYS. A bookmark is an object with: bookmark == bookmarktype(str(instance)) Which is true for str or FileSystemObject. This condition is required so bookmark-objects can be saved to and loaded from a file. Optionally, a bookmark.go() method is used for entering a bookmark. """ last_mtime = None autosave = True load_pattern = re.compile(r"^[\d\w']:.") def __init__(self, bookmarkfile, bookmarktype=str, autosave=False): """Initializes Bookmarks. <bookmarkfile> specifies the path to the file where bookmarks are saved in. """ self.autosave = autosave self.dct = {} self.path = bookmarkfile self.bookmarktype = bookmarktype def load(self): """Load the bookmarks from path/bookmarks""" try: new_dict = self._load_dict() except OSError: return self._set_dict(new_dict, original=new_dict) def delete(self, key): """Delete the bookmark with the given key""" if key == '`': key = "'" if key in self.dct: del self.dct[key] if self.autosave: self.save() def enter(self, key): """Enter the bookmark with the given key. Requires the bookmark instance to have a go() method. """ try: return self[key].go() except (IndexError, KeyError, AttributeError): return False def update_if_outdated(self): if self.last_mtime != self._get_mtime(): self.update() def remember(self, value): """Bookmarks <value> to the key '""" self["'"] = value if self.autosave: self.save() def __iter__(self): return iter(self.dct.items()) def __getitem__(self, key): """Get the bookmark associated with the key""" if key == '`': key = "'" if key in self.dct: return self.dct[key] else: raise KeyError("Nonexistant Bookmark: `%s'!" % key) def __setitem__(self, key, value): """Bookmark <value> to the key <key>. key is expected to be a 1-character string and element of ALLOWED_KEYS. value is expected to be a filesystemobject. """ if key == '`': key = "'" if key in ALLOWED_KEYS: self.dct[key] = value if self.autosave: self.save() def __contains__(self, key): """Test whether a bookmark-key is defined""" return key in self.dct def update(self): """Update the bookmarks from the bookmark file. Useful if two instances are running which define different bookmarks. """ try: real_dict = self._load_dict() real_dict_copy = real_dict.copy() except OSError: return for key in set(self.dct.keys()) | set(real_dict.keys()): # set some variables if key in self.dct: current = self.dct[key] else: current = None if key in self.original_dict: original = self.original_dict[key] else: original = None if key in real_dict: real = real_dict[key] else: real = None # determine if there have been changes if current == original and current != real: continue # another ranger instance has changed the bookmark if key not in self.dct: del real_dict[key] # the user has deleted it else: real_dict[key] = current # the user has changed it self._set_dict(real_dict, original=real_dict_copy) def save(self): """Save the bookmarks to the bookmarkfile. This is done automatically after every modification if autosave is True.""" self.update() if self.path is None: return if os.access(self.path, os.W_OK): f = open(self.path+".new", 'w') for key, value in self.dct.items(): if type(key) == str\ and key in ALLOWED_KEYS: try: f.write("{0}:{1}\n".format(str(key), str(value))) except: pass f.close() os.rename(self.path+".new", self.path) self._update_mtime() def _load_dict(self): dct = {} if self.path is None: return dct if not os.path.exists(self.path): try: f = open(self.path, 'w') except: raise OSError('Cannot read the given path') f.close() if os.access(self.path, os.R_OK): f = open(self.path, 'r') for line in f: if self.load_pattern.match(line): key, value = line[0], line[2:-1] if key in ALLOWED_KEYS: dct[key] = self.bookmarktype(value) f.close() return dct else: raise OSError('Cannot read the given path') def _set_dict(self, dct, original): if original is None: original = {} self.dct.clear() self.dct.update(dct) self.original_dict = original self._update_mtime() def _get_mtime(self): if self.path is None: return None try: return os.stat(self.path).st_mtime except OSError: return None def _update_mtime(self): self.last_mtime = self._get_mtime()