Skip to content

Context help#8355

Closed
ThomasStivers wants to merge 26 commits into
nvaccess:masterfrom
ThomasStivers:contextHelp
Closed

Context help#8355
ThomasStivers wants to merge 26 commits into
nvaccess:masterfrom
ThomasStivers:contextHelp

Conversation

@ThomasStivers

Copy link
Copy Markdown
Contributor

Link to issue number:

#8354

Summary of the issue:

Add context sensitive help referencing the user guide to settings dialogs, panels, and controls.

Description of how this pull request fixes the issue:

Using anchors previously added to the user guide this patch adds helpIds dictionaries to panels and dialogs referencing user guide sections. Pressing F1 or the help button will open an HTML fiewer to the appropriate section of the user guide.

Testing performed:

This code is very much alpha. It works as expected for some controls, but I am new to working on NVDA code, so I am seeking suggestions and assistance from the community.

Known issues with pull request:

Help is not yet implemented across all controls.

Change log entry:

  • New features

* Added named anchors to the user guide which can be linked to from help events.
* Added Help button to all settings dialogs which opens help for all controls in that dialog.
* Dynamically generated dictionary of control ids and anchor names including controls in any open settings dialog.

This work may eventually be separated into its own module so it can be used in all NVDA generated dialogs.
@josephsl

josephsl commented Jun 1, 2018 via email

Copy link
Copy Markdown
Contributor

@derekriemer derekriemer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. A few comments here.

Also, can you list what still needs help? I am a bit worried about the ease of forgetting to include help, is there a way we could abstract help more so it is provided easier to any new NVDA dialog? I'm afraid not, but we might want to discuss it.

ProfilesDialog._instance = self
# Translators: The title of the Configuration Profiles dialog.
super(ProfilesDialog, self).__init__(parent, title=_("Configuration Profiles"))
self.helpIds[self.GetId()] = "ConfigurationProfiles"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: are these translated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchors in the user guide are not translated, but the help text which loads should be in the users language.

Comment thread user_docs/global.t2tconf Outdated
@@ -1,22 +1,22 @@
%!Target: html
%!Target: xhtml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change the format?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary at this point, but I had been working on parsing the user guide as XML instead of treating it as plain text.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code you call alpha, I think you did a pretty good job here.

I think it would be good to have some discussion about the HTML parsing. It looks like you decided to use the xml module at some point, than switched to read the user guide html line by line. The latter approach seems a bit error prone to me.

In any case, it might be good to cache the contents of the user guide file after the first load. Something like this, note that the variable names are indicative:

lines = ""
def getCachedFileContents(file):
    global lines
    if lines:
        return lines
	try:
		with open(helpFile) as help:
			lines = help.readlines()
	except:
		lines = ""
 return lines

def txt2tags_actionFunc(target,source,env):
import txt2tags
txt2tags.exec_command_line([str(source[0])])
txt2tags.exec_command_line(["--outfile", str(source[0])[:-3] + "html", str(source[0])])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on why you made this change?

Comment thread source/contextHelp.py Outdated
from logHandler import log
from xml.etree import ElementTree

class Help():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class doesn't seem to be used anywhere. Note that class names usually start with an upper case letter and inherrit from object.

Comment thread source/contextHelp.py Outdated
@@ -0,0 +1,60 @@
# -*- coding: UTF-8 -*-

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to put this in the gui module, i.e. gui/contextHelp.py

* Use lxml.html to parse the user guide instead of working with text offsets directly.
* Moved contextHelp into the gui module.
* Removed unnecessary help class from contextHelp.
* Add dependency on lxml module for iterating through sibling elements in the user guide.
* Ensure that proper help ids are added for the category list and help button.
* Update helpIds from new panels do not replace the old list.
* Some anchors were changed upstream, so updated this PR to match.
@derekriemer

Copy link
Copy Markdown
Collaborator

@ThomasStivers looks like CI unit tests are failing.

@ThomasStivers

Copy link
Copy Markdown
Contributor Author

Yes it is failing a test.

py scons.py tests %sconsArgs%
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
C:\Python27\python.exe -m unittest discover tests.unit -t .
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\Python27\lib\unittest_main
.py", line 12, in
main(module=None)
File "C:\Python27\lib\unittest\main.py", line 94, in init
self.parseArgs(argv)
File "C:\Python27\lib\unittest\main.py", line 113, in parseArgs
self._do_discovery(argv[2:])
File "C:\Python27\lib\unittest\main.py", line 214, in _do_discovery
self.test = loader.discover(start_dir, pattern, top_level_dir)
File "C:\Python27\lib\unittest\loader.py", line 204, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: 'tests.unit'
scons: *** [tests\unit] Error 1
scons: building terminated because of errors.
Command exited with code 2

I am not sure what %sconsArgs% contains, but when I run python scons.py tests locally it completes successfully.

I needed to use the lxml package which I have installed locally with pip install lxml, but i do not know how to make it a dependency. I have lxml included as a git submodule, but I am looking for pointers on how to build it when NVDA builds. That is my only guess to what is causing the CI build to fail.

@feerrenrut

Copy link
Copy Markdown
Contributor

Rather than build lxml, create a new repo holding the prebuilt dependency. You can use pip install -t ./ lxml (while in an appropriate directory). Add a new submodule to NVDA pointing at this new repo.

Perhaps we don't need the lxml dependency. Splitting up the userguide file programmatically might cause maintenance issues in the future. There has been some talk of using different formats for these files.

The simplest approach is to load the whole user guide, presented (using a html viewer) with the target url set to point to the anchor.

An alternative approach, is to break up the userGuide.t2t into multiple files. One per section. The user guide can then be constructed by recombining these sections. Some investigation will be required on how to achieve this. My first thought would be to programatically concatenate each of the sections, and generate the html from those combined, but this leads to ordering issues.

Another way would be to convert the userGuide.t2t into a template file, which uses the t2t include command to pull in each of the subsections.
The help ID's would match the name of the subsection file (or perhaps use a mapping file), and then each subsection could be displayed directly.

@dpy013

dpy013 commented May 22, 2019

Copy link
Copy Markdown
Contributor

This PR has the following error during the build
Failure: AppVeyor build failed
Can you fix it?
thank?

@feerrenrut

Copy link
Copy Markdown
Contributor

We are interested in getting this feature merged, is anyone willing to take on the remaining issues:

@josephsl

josephsl commented May 6, 2020

Copy link
Copy Markdown
Contributor

Hi,

I'll try at least fixing possible conflicts and Python 3 compatibility.

Thanks.

@josephsl

josephsl commented May 6, 2020

Copy link
Copy Markdown
Contributor

Hi,

Dear me... Conflict resolution will involve not only checking Python 3 syntax gotchas, but also wxPython 4 changes, imports, copyright header, coding style updates... As much as I wish to continue to try and resolve hundreds of potential conflicts, it will take time, risking other life priorities and mental health (and I'm not really in a position to do it in the near term).

I propose three possibilities for this PR:

  1. Recommend starting from scratch: this is perhaps the easiest yet most difficult, most painful possibility, as it'll involve recreating what is essentially an almost complete product.
  2. Request community help: this will involve folks looking at what's going on and try to make sense of what needs to be done.
  3. Ask @ThomasStivers to respond to feedback: this depends on willingness from him to take a look at feedback and doing something about them, which I imagine would be painful at first.

I think a combination of options 2 and 3 would be the best path forward: letting the community help out in essentially making a "phoenix" out of it, with Thomas providing guidance. As of now, I'm giving up.

Thanks.

@feerrenrut

Copy link
Copy Markdown
Contributor

Given the lack of updates, I would consider this PR abandoned, and that is fine. I think this would be a valuable feature. I think the most important thing is to validate this approach, the biggest outstanding unknown is the use of lxml. To progress this work, I would suggest taking just the new file source/gui/contextHelp.py and the changes from one file that maps a help topic eg: source/speechViewer.py and then resolve the issues with lxml. I'm going to convert this PR to a draft.

@feerrenrut feerrenrut marked this pull request as draft May 6, 2020 09:38
@feerrenrut feerrenrut added Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. component/user-documentation labels May 6, 2020
@josephsl

josephsl commented May 6, 2020

Copy link
Copy Markdown
Contributor

Hi,

Looking at small things at the moment (speech viewer):

we need Python 3.7 specific lxml module, as the one Thomas used was optimized for Python 2.7+Cython. Even then, we need to consider str/bytes conversion and what not, along with converting context help module to Python 3 (along with dropping hints for Python 3.8).

Therefore, I propose the following:

  1. Experiment with Python 3.7 version of lxml (4.5.0).
  2. Convert context help module to Python 3.
  3. Test it on a small scale (speech viewer is the best candidate for it).
  4. Expand this to other controls.
  5. Investigate possible route for combining with INSERT+F1 help message capability #2699 (after this PR is merged) so the dedicated context-sensitive help gesture can work across various scenarios (NVDA objects, app modules, NVDA controls and others).
  6. Investigate a possible route for add-ons to participate in providing help in their interfaces (later).

Thanks.

@feerrenrut feerrenrut self-assigned this Jul 3, 2020
@feerrenrut feerrenrut mentioned this pull request Aug 3, 2020
@feerrenrut

Copy link
Copy Markdown
Contributor

Superseded by #11456

@feerrenrut feerrenrut closed this Aug 3, 2020
feerrenrut added a commit that referenced this pull request Sep 9, 2020
Fixes #7757
Fixes #8354
Supersedes PR #8355

Add initial support for opening the user guide at a particular section based on the context when the user presses F1 (in NVDA dialogs). For the sake of simplicity, this is done by opening the user guide in the browser. Unfortunately, this results in a lot of unnecessary verbosity. However, this is still quicker for the user than manually opening the user guide separately (also in a browser) and navigating to the chosen section manually. 

Co-authored-by: ThomasStivers <thomas.stivers@gmail.com>
Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
dawidpieper pushed a commit to dawidpieper/nvda that referenced this pull request Sep 13, 2020
Fixes nvaccess#7757
Fixes nvaccess#8354
Supersedes PR nvaccess#8355

Add initial support for opening the user guide at a particular section based on the context when the user presses F1 (in NVDA dialogs). For the sake of simplicity, this is done by opening the user guide in the browser. Unfortunately, this results in a lot of unnecessary verbosity. However, this is still quicker for the user than manually opening the user guide separately (also in a browser) and navigating to the chosen section manually. 

Co-authored-by: ThomasStivers <thomas.stivers@gmail.com>
Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
@CyrilleB79 CyrilleB79 removed the Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants