Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The documentation editing tool with changes to support it. #2518

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

cbhaley
Copy link
Contributor

@cbhaley cbhaley commented Nov 13, 2024

It is an action so it can be opened easily, should a document writer want to use it. It is also available in the Stored templates / User functions dialog.

It is possible that no one other than me will use it. :)

@kovidgoyal
Copy link
Owner

I'd rather it not be an action as it clutters the list of available
actions with something that almost no-one will use. Any template doc
writers can always launch it easily enough using a calibre-debug -c
command or from the template dialog which is the natural place to look
for it anyway.

@cbhaley
Copy link
Contributor Author

cbhaley commented Nov 13, 2024

  1. How do I run it with calibre-debug -c? I assume there must be some sort of entry point somewhere.
  2. What template dialog? The template tester isn't really a place for it because nothing is edited there. The Stored templates dialog uses it to edit the documentation for the user template/function being edited, which isn't the same thing.

@cbhaley
Copy link
Contributor Author

cbhaley commented Nov 13, 2024

OK, I solved the calibre-debug -c by using if name == 'main'. The only problem is that it doesn't remember geometry, but that isn't a huge problem.

@cbhaley
Copy link
Contributor Author

cbhaley commented Nov 13, 2024

FWIW: with this code:

if __name__ == '__main__':
    from tempfile import TemporaryDirectory
    from calibre.db.legacy import LibraryDatabase
    from calibre.gui2 import Application

    with TemporaryDirectory() as tdir:
        app = Application([])
        db = LibraryDatabase(tdir) # needed to load formatter_funcs
        d = FFDocEditor(None)
        d.exec()
        del app

I get this exception when exiting

    with TemporaryDirectory() as tdir:
  File "tempfile.py", line 904, in __exit__
  File "tempfile.py", line 908, in cleanup
  File "tempfile.py", line 890, in _rmtree
  File "shutil.py", line 759, in rmtree
  File "shutil.py", line 617, in _rmtree_unsafe
  File "shutil.py", line 622, in _rmtree_unsafe
  File "tempfile.py", line 881, in onerror
  File "tempfile.py", line 890, in _rmtree
  File "shutil.py", line 759, in rmtree
  File "shutil.py", line 603, in _rmtree_unsafe
  File "shutil.py", line 600, in _rmtree_unsafe
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\Charles\\AppData\\Local\\Temp\\tmpj1_vj_j6\\.calnotes\\notes.db'

It leaves the temp directory undeleted.

@cbhaley cbhaley closed this Nov 13, 2024
@cbhaley cbhaley reopened this Nov 13, 2024
@cbhaley
Copy link
Contributor Author

cbhaley commented Nov 13, 2024

Pushed commit to remove the action and to add the main code.

@cbhaley
Copy link
Contributor Author

cbhaley commented Nov 13, 2024

Do you object to a non-action keyboard shortcut defined in gui2.ui, similar to 'Minimize the calibre window' and 'focus book list'? This allows someone to easily get to the editor without cluttering up the list of actions. I'd make it discoverable via a comment in formatter_functions.py.

@kovidgoyal kovidgoyal merged commit 7430a74 into kovidgoyal:master Nov 13, 2024
8 checks passed
@kovidgoyal
Copy link
Owner

kovidgoyal commented Nov 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants